Reinforced reaction_message management and interaction, better split responsibilty of tasks across files and functions.

UUID is now used as primary key for reaction_messages.
This commit is contained in:
DefsNotQuack
2025-03-30 17:34:47 +10:00
parent e00d1fdce3
commit 30bab81007
8 changed files with 389 additions and 286 deletions

20
main.py
View File

@@ -27,35 +27,33 @@ COG_PATH = Path(__file__).resolve().parent / "cogs"
cogs_available = {}
loaded_cog_modules = {}
# Arguments used in cog loading
COG_CONFIG = {
"react_roles": {
"guild_ids": [DEV_GUILD_ID],
"react_channel_id": REACT_ROLE_CHANNEL_ID
}
}
# Add available cogs to the list
for file in COG_PATH.iterdir():
if file.suffix == ".py" and not file.name.startswith("__"):
cog_name = file.stem
cogs_available[cog_name] = file
############################
### COGS LOADING HANDLER ###
############################
async def load_cogs():
# Check if there are any cogs to load
if not cogs_available:
console.log("[yellow]⚙️ No cogs available to load...[/yellow]")
return
# Check if the cogs directory exists
if not COG_PATH.exists():
console.log(f"[red]❌ Cogs directory not found at {COG_PATH}[/red]")
return
console.print(panel(content="🔌 [bold]Loading Cogs[/bold]", style="cyan"))
# Load each cog
for cog in track(cogs_available, description="Loading Cogs..."):
module_path = f"cogs.{cog}"
config = COG_CONFIG.get(cog, {})
try:
bot.load_extension(module_path)
loaded_cog_modules[cog] = module_path
@@ -71,10 +69,10 @@ async def shutdown():
await bot.close()
def handle_signals():
# Handle shutdown signals
for sig in (signal.SIGINT, signal.SIGTERM):
signal.signal(sig, lambda s, f: asyncio.create_task(shutdown()))
# Bot Event Handlers
@bot.event
async def on_ready():