From 16733406364b182f90c0dd2de03ac4d3fa00d2a4 Mon Sep 17 00:00:00 2001 From: Natasha Moongrave Date: Wed, 1 Apr 2026 18:47:33 +0200 Subject: Added partially finished things for extra functionality --- bot.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'bot.py') diff --git a/bot.py b/bot.py index ea69475..0f0d597 100644 --- a/bot.py +++ b/bot.py @@ -2,12 +2,21 @@ import discord from discord import app_commands from discord.ext import commands import random +import asyncio from proxmoxer import ProxmoxAPI import config +from utils.database import Database bot = commands.Bot(command_prefix="!", intents=discord.Intents.default()) tree = bot.tree +# List of cogs to load +COGS = [ + "cogs.commissions", + "cogs.vm_management", + "cogs.alerts", +] + def get_proxmox(): return ProxmoxAPI( @@ -19,9 +28,27 @@ def get_proxmox(): ) +async def load_cogs(): + """Load all cogs.""" + for cog in COGS: + try: + await bot.load_extension(cog) + print(f"Loaded cog: {cog}") + except Exception as e: + print(f"Failed to load cog {cog}: {e}") + + @bot.event async def on_ready(): print(f"Logged in as {bot.user} (ID: {bot.user.id})") + + # Initialize database tables + try: + await Database.init_tables() + print("Database tables initialized") + except Exception as e: + print(f"Failed to initialize database: {e}") + try: synced = await tree.sync() print(f"Synced {len(synced)} command(s)") @@ -221,6 +248,12 @@ async def notify(interaction: discord.Interaction, user: discord.User, message: await interaction.response.send_message(f"Failed to send notification: {e}", ephemeral=True) +async def main(): + async with bot: + await load_cogs() + await bot.start(config.DISCORD_TOKEN) + + if __name__ == "__main__": - bot.run(config.DISCORD_TOKEN) + asyncio.run(main()) -- cgit v1.2.3