-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
37 lines (29 loc) · 1.06 KB
/
Copy pathmain.py
File metadata and controls
37 lines (29 loc) · 1.06 KB
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
import os
import asyncio
import importlib
import traceback
from typing import Optional
from dotenv import load_dotenv
from discord.ext.commands import Bot
import discord
from config import settings
load_dotenv()
BOT: Bot = Bot(command_prefix=',', help_command=None, intents=discord.Intents.all())
# load all cogs dynamically from ./cogs
async def load_cogs(bot: Bot) -> None:
for root, _, files in os.walk("cogs"):
for file in files:
if file.endswith(".py") and file != "__init__.py":
cog_path = os.path.relpath(os.path.join(root, file)).replace(os.path.sep, '.')[:-3]
try:
module = importlib.import_module(cog_path)
if getattr(module, "COG", False):
await bot.load_extension(cog_path)
print(f"Loaded cog: {cog_path}")
except Exception:
traceback.print_exc()
async def main() -> None:
await load_cogs(BOT)
await BOT.start(settings.token)
if __name__ == "__main__":
asyncio.run(main())