Refactor: remove unused cogs and services, simplify architecture

- Remove admin.py and search.py cogs
- Remove searxng.py service and rate_limiter.py utility
- Update bot.py, ai_chat.py, config.py, and ai_service.py
- Update documentation and docker-compose.yml
This commit is contained in:
2026-01-11 18:41:23 +01:00
parent 0607b05e3b
commit b05fa034a6
14 changed files with 182 additions and 801 deletions

View File

@@ -12,7 +12,7 @@ logger = logging.getLogger(__name__)
class DaemonBoyfriend(commands.Bot):
"""The main bot class for Daemon Boyfriend."""
"""The main bot class."""
def __init__(self) -> None:
intents = discord.Intents.default()
@@ -21,13 +21,13 @@ class DaemonBoyfriend(commands.Bot):
intents.members = True
super().__init__(
command_prefix=settings.command_prefix,
command_prefix="!", # Required but not used
intents=intents,
help_command=None, # We use slash commands instead
help_command=None,
)
async def setup_hook(self) -> None:
"""Load cogs and sync commands on startup."""
"""Load cogs on startup."""
# Load all cogs
cogs_path = Path(__file__).parent / "cogs"
for cog_file in cogs_path.glob("*.py"):
@@ -40,18 +40,6 @@ class DaemonBoyfriend(commands.Bot):
except Exception as e:
logger.error(f"Failed to load cog {cog_name}: {e}")
# Sync slash commands
if settings.discord_guild_id:
# Sync to specific guild for faster testing (instant)
guild = discord.Object(id=settings.discord_guild_id)
self.tree.copy_global_to(guild=guild)
await self.tree.sync(guild=guild)
logger.info(f"Synced commands to guild {settings.discord_guild_id}")
else:
# Global sync (can take up to 1 hour to propagate)
await self.tree.sync()
logger.info("Synced commands globally")
async def on_ready(self) -> None:
"""Called when the bot is ready."""
if self.user is None:
@@ -59,31 +47,11 @@ class DaemonBoyfriend(commands.Bot):
logger.info(f"Logged in as {self.user} (ID: {self.user.id})")
logger.info(f"Connected to {len(self.guilds)} guild(s)")
logger.info(f"Bot name: {settings.bot_name}")
# Set activity status
# Set activity status from config
activity = discord.Activity(
type=discord.ActivityType.watching,
name="over the MSC group",
name=settings.bot_status,
)
await self.change_presence(activity=activity)
async def on_command_error(
self,
ctx: commands.Context,
error: commands.CommandError, # type: ignore[type-arg]
) -> None:
"""Global error handler for prefix commands."""
if isinstance(error, commands.CommandNotFound):
return # Ignore unknown commands
if isinstance(error, commands.MissingPermissions):
await ctx.send("You don't have permission to use this command.")
return
if isinstance(error, commands.CommandOnCooldown):
await ctx.send(f"Command on cooldown. Try again in {error.retry_after:.1f}s")
return
# Log unexpected errors
logger.error(f"Command error: {error}", exc_info=error)
await ctx.send("An unexpected error occurred.")