import os import asyncio import discord from cogs.database import Database from discord.ext import commands from dotenv import load_dotenv load_dotenv() intents = discord.Intents.default() intents.message_content = True intents.members = True bot = commands.Bot(command_prefix=None, intents=intents) @bot.event async def on_ready(): print(f"Logged in as {bot.user} (ID: {bot.user.id})") print("------") await bot.database.connect() print("Database connected!") try: synced = await bot.tree.sync() print(f"Synced {len(synced)} command(s) successfully!") except Exception as e: print(f"Failed to sync commands: {e}") @bot.event async def on_disconnect(): await bot.database.close() async def load_extensions(): for filename in os.listdir("./commands"): if filename.endswith(".py"): await bot.load_extension(f"commands.{filename[:-3]}") print(f"Loaded extension: commands.{filename[:-3]}") for filename in os.listdir("./extensions"): if filename.endswith(".py"): await bot.load_extension(f"extensions.{filename[:-3]}") print(f"Loaded extension: extensions.{filename[:-3]}") if os.getenv("DEV_MODE") == "True": for filename in os.listdir("./dev"): if filename.endswith(".py"): await bot.load_extension(f"dev.{filename[:-3]}") print(f"Loaded extension: dev.{filename[:-3]}") async def main(): async with bot: bot.database = Database() await load_extensions() try: await bot.start(os.getenv("DISCORD_TOKEN")) except KeyboardInterrupt: pass if __name__ == "__main__": try: asyncio.run(main()) except KeyboardInterrupt: print("\nShutting down... byeeeeee :3 👋")