From 429d9525baf3d19ed3626d939b07d1732f59b8a8 Mon Sep 17 00:00:00 2001 From: Slipstream Date: Mon, 19 May 2025 14:51:00 -0600 Subject: [PATCH] fix: Update cog loading mechanism to load specific cogs only --- README.md | 2 +- neru_bot.py | 28 +++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index da5f930..42fdcca 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ python api_service/api_server.py - Default prefix: `!` (same as main bot) - Uses global command syncing instead of per-guild - All commands work in DMs and private channels -- Identical functionality to main bot but with different command registration +- Loads only a limited set of cogs (settings, help, message, webdrivertorso, owoify, safebooru, rule34, starboard, wordle) ## 🧩 Project Structure diff --git a/neru_bot.py b/neru_bot.py index 0c067ef..c578be8 100644 --- a/neru_bot.py +++ b/neru_bot.py @@ -7,7 +7,6 @@ import asyncio import logging import asyncpg import redis.asyncio as aioredis -from commands import load_all_cogs from error_handler import handle_error import settings_manager from global_bot_accessor import set_bot_instance @@ -84,12 +83,31 @@ class NeruBot(commands.Bot): else: log.error("CRITICAL: pg_pool or redis_client not initialized in setup_hook. Cannot proceed with settings_manager setup.") - # Load all cogs + # Load only specific cogs try: - await load_all_cogs(self) - log.info("All cogs loaded successfully") + # Define the hardcoded list of cogs to load + hardcoded_cogs = [ + "cogs.settings_cog", + "cogs.help_cog", + "cogs.message_cog", + "cogs.owoify_cog", + "cogs.safebooru_cog", + "cogs.caption_cog", + "cogs.games_cog", + "cogs.ping_cog", + ] + + # Load each cog individually + for cog in hardcoded_cogs: + try: + await self.load_extension(cog) + log.info(f"Successfully loaded {cog}") + except Exception as e: + log.exception(f"Error loading cog {cog}: {e}") + + log.info(f"Loaded {len(hardcoded_cogs)} hardcoded cogs") except Exception as e: - log.exception(f"Error loading cogs: {e}") + log.exception(f"Error during cog loading process: {e}") # Apply global allowed_installs and allowed_contexts to all commands try: