-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
55 lines (42 loc) · 1.58 KB
/
main.py
File metadata and controls
55 lines (42 loc) · 1.58 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import os
import discord
from discord.ext import commands
from dotenv import load_dotenv
from utils.logger import logger
from utils.config_watcher import config_watcher
from views.main_menu import MainMenuView
from services.role_service import role_service
load_dotenv()
TOKEN = os.getenv("BOT_TOKEN")
class SuperRoleManager(commands.Bot):
# No one really knows how to fix those warnings properly nowdays
# noinspection PyDunderSlots,PyUnresolvedReferences
def __init__(self):
intents = discord.Intents.default()
intents.message_content = True
intents.members = True
super().__init__(command_prefix="role!", intents=intents, help_command=None)
async def on_ready(self):
self.add_view(MainMenuView())
logger.debug("Persistent views loaded.")
try:
self.load_extension("cogs.role_menu")
except Exception as e:
logger.exception(f"Failed to load extension cogs.role_menu: {e}")
if self.user:
logger.info(f"Logged in as {self.user} (ID: {self.user.id})")
logger.debug(f"Loaded {len(role_service.categories)} categories from config.")
# Start the config watcher for hot reload
config_watcher.start()
if __name__ == "__main__":
if not TOKEN:
logger.critical("BOT_TOKEN not found in .env file.")
else:
import asyncio
try:
loop = asyncio.get_event_loop()
except RuntimeError:
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
bot = SuperRoleManager()
bot.run(TOKEN)