-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
54 lines (46 loc) · 2 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import lightbulb
import logging
import os
import hikari
from dotenv import load_dotenv
load_dotenv()
bot = lightbulb.BotApp(token=os.getenv("DISCORD_TOKEN"),
prefix="!",
logs={
"version": 1,
"incremental": True,
"loggers": {
"hikari": {
"level": "INFO"
},
"hikari.ratelimits": {
"level": "TRACE_HIKARI"
},
"lightbulb": {
"level": "INFO"
},
},
},
intents=hikari.Intents.ALL)
bot.load_extensions("extensions.moderation")
# slash command to reload an extension (only available in guild 941744574529957898 and only invokable by the bot owner))
@bot.command
@lightbulb.option("extension", "The extension to reload", type=str)
@lightbulb.command("reload", "Reloads an extension")
@lightbulb.implements(lightbulb.SlashCommand)
async def reload(ctx: lightbulb.SlashContext) -> None:
if ctx.author.id == 712439467901976660:
try:
bot.reload_extensions(f"extensions.{ctx.options.extension}")
await ctx.respond(embed=hikari.Embed(
title="Reloaded!",
description=f"Reloaded extension {ctx.options.extension}",
color=hikari.Color.from_rgb(0, 255, 0)),
flags=hikari.MessageFlag.EPHEMERAL)
except lightbulb.errors.ExtensionNotLoaded:
await ctx.respond(embed=hikari.Embed(
title="Error!",
description=f"Extension {ctx.options.extension} is not loaded!",
color=hikari.Color.from_rgb(255, 0, 0)),
flags=hikari.MessageFlag.EPHEMERAL)
bot.run()