-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
78 lines (70 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import disnake, os
from disnake.ext import commands
from config import BOT_TOKEN, SERVER, VERSION
bot = commands.Bot(command_prefix=commands.when_mentioned, intents=disnake.Intents.all())
for filename in os.listdir("Cogs"):
if filename.endswith(".py"):
bot.load_extension(f"Cogs.{filename[:-3]}")
@bot.event
async def on_ready():
print(f"Ready! {bot.user.name}#{bot.user.discriminator}")
await bot.change_presence(activity=disnake.Game(name=f"{VERSION}"))
@bot.event
async def on_thread_create(thread: disnake.Thread):
if thread.guild.id == 812664224512868382:
await thread.join()
@bot.slash_command(
name="reload",
description="Reload Module (Cogs)",
guild_ids=[812664224512868382]
)
async def reloadCogs(
i: disnake.CommandInteraction,
file: str = commands.Param(
name="module",
description="Module name."
)
):
try:
bot.reload_extension(name=f"Cogs.{file}")
await i.response.send_message(":white_check_mark: Reload completed.")
except Exception as e:
print(e)
await i.response.send_message(":x: Reload failed.")
@bot.slash_command(
name="load",
description="Reload Module (Cogs)",
guild_ids=[812664224512868382]
)
async def loadCogs(
i: disnake.CommandInteraction,
file: str = commands.Param(
name="module",
description="Module name."
)
):
try:
bot.load_extension(name=f"Cogs.{file}")
await i.response.send_message(":white_check_mark: Load completed.")
except Exception as e:
print(e)
await i.response.send_message(":x: Load failed.")
@bot.slash_command(
name="unload",
description="Unload Module (Cogs)",
guild_ids=[812664224512868382]
)
async def unloadCogs(
i: disnake.CommandInteraction,
file: str = commands.Param(
name="module",
description="Module name."
)
):
try:
bot.load_extension(name=f"Cogs.{file}")
await i.response.send_message(":white_check_mark: Unload completed.")
except Exception as e:
print(e)
await i.response.send_message(":x: Unload failed.")
bot.run(BOT_TOKEN[SERVER])