-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
101 lines (77 loc) · 2.82 KB
/
main.py
File metadata and controls
101 lines (77 loc) · 2.82 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import discord
from discord.ext import commands
import os
from dotenv import load_dotenv
# Import Tourney Logic (Legacy/Features folder)
from features.tourney.tourney_commands import (
setup_tourney_commands,
restore_tourney_panels,
)
# Import Database connection check
from database.mongo import db
load_dotenv()
# --- CONFIGURATION ---
intents = discord.Intents.default()
intents.message_content = True
intents.members = True
intents.invites = True
# Initialize Bot
bot = commands.Bot(command_prefix="!", intents=intents)
# --- EVENTS ---
@bot.event
async def on_ready():
print(f"✅ Logged in as {bot.user}")
# 1. Check Database Connection
if db is not None:
print("✅ MongoDB Connected via 'database.mongo'")
else:
print("❌ MongoDB Connection Failed (Check .env and MONGO_URI)")
# 2. Load Features (Cogs)
try:
# Load General Feature
await bot.load_extension("features.general")
print("✅ Loaded Feature: General")
await bot.load_extension("features.economy")
print("✅ Loaded Feature: Economy")
await bot.load_extension("features.event")
print("✅ Loaded Feature: Event")
# Load Security/Hacked Feature
await bot.load_extension("features.security")
print("✅ Loaded Feature: Security (Hacked)")
await bot.load_extension("features.brawl.commands")
print("✅ Loaded Feature: Brawl (Drops)")
# Load Quests Feature
await bot.load_extension("features.quests")
print("✅ Loaded Feature: Quests")
# Load Translation Feature
await bot.load_extension("features.translation")
print("✅ Loaded Feature: Translation")
await bot.load_extension("features.support_tickets")
print("✅ Loaded Feature: Support Tickets")
except Exception as e:
print(f"❌ Error loading features: {e}")
# 3. Load Tourney System
try:
setup_tourney_commands(bot)
print("✅ Loaded Feature: Tournaments")
await restore_tourney_panels(bot)
except Exception as e:
print(f"⚠️ Tourney Error: {e}")
# 4. SYNC COMMANDS (Do this LAST)
try:
# This registers /shop, /buy, /tourney, /audit_emojis etc.
synced = await bot.tree.sync()
print(f"✅ Slash Commands Synced: {len(synced)} commands available")
except Exception as e:
print(f"⚠️ Command Sync Error: {e}")
print("🚀 Bot Startup Complete!")
if __name__ == "__main__":
MODE = os.getenv("BOT_MODE", "DEV").upper()
token = os.getenv("PROD_TOKEN") if MODE == "PROD" else os.getenv("DEV_TOKEN")
if token:
try:
bot.run(token)
except Exception as e:
print(f"❌ Runtime Error: {e}")
else:
print("❌ Token not found in .env file. Set PROD_TOKEN or DEV_TOKEN.")