aboutsummaryrefslogtreecommitdiff
path: root/bot.py
diff options
context:
space:
mode:
Diffstat (limited to 'bot.py')
-rw-r--r--bot.py35
1 files changed, 34 insertions, 1 deletions
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())