-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
66 lines (49 loc) · 1.81 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
import os
import discord
from discord.ext import commands
from logger import setup_logger
from config import DISCORD_TOKEN, LOG_CHANNEL_ID
from models.CustomMogiContext import MogiApplicationContext
logger = setup_logger(__name__)
intents = discord.Intents.all()
class YuzuLoungeBot(commands.Bot):
"""
A custom Discord bot class for the Yuzu Lounge server.
This class extends the `commands.Bot` class from the `discord.ext.commands` module.
"""
def __init__(self, *args, **kwargs):
return super().__init__(*args, **kwargs)
async def get_application_context(self, interaction, cls=MogiApplicationContext):
return await super().get_application_context(interaction, cls=cls)
async def close(self):
if channel := self.get_channel(LOG_CHANNEL_ID):
await channel.send("🔄 Bot is shutting down...")
for name, cog in self.cogs.items():
cog._eject(self)
print(f"Ejected {name}")
await super().close()
bot = YuzuLoungeBot(
command_prefix=".",
case_insensitive=True,
help_command=None,
intents=intents,
status=discord.Status.online,
activity=discord.Streaming(
name="bytes for booting...", url="https://www.youtube.com/watch?v=xvFZjo5PgG0"
),
)
def main():
print("----Loading extensions----")
for root, dirs, files in os.walk("./cogs"):
for file in files:
if file.endswith(".py"):
cog_path = os.path.join(root, file)
extension = (
cog_path[2:].replace("/", ".").replace("\\", ".").replace(".py", "")
)
bot.load_extension(extension)
print(f"Loaded {extension}")
logger.debug("*Finished loading extensions*")
bot.run(DISCORD_TOKEN)
if __name__ == "__main__":
main()