- 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
58 lines
1.7 KiB
Python
58 lines
1.7 KiB
Python
"""Main Discord bot class."""
|
|
|
|
import logging
|
|
from pathlib import Path
|
|
|
|
import discord
|
|
from discord.ext import commands
|
|
|
|
from daemon_boyfriend.config import settings
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class DaemonBoyfriend(commands.Bot):
|
|
"""The main bot class."""
|
|
|
|
def __init__(self) -> None:
|
|
intents = discord.Intents.default()
|
|
intents.message_content = True
|
|
intents.guilds = True
|
|
intents.members = True
|
|
|
|
super().__init__(
|
|
command_prefix="!", # Required but not used
|
|
intents=intents,
|
|
help_command=None,
|
|
)
|
|
|
|
async def setup_hook(self) -> None:
|
|
"""Load cogs on startup."""
|
|
# Load all cogs
|
|
cogs_path = Path(__file__).parent / "cogs"
|
|
for cog_file in cogs_path.glob("*.py"):
|
|
if cog_file.name.startswith("_"):
|
|
continue
|
|
cog_name = f"daemon_boyfriend.cogs.{cog_file.stem}"
|
|
try:
|
|
await self.load_extension(cog_name)
|
|
logger.info(f"Loaded cog: {cog_name}")
|
|
except Exception as e:
|
|
logger.error(f"Failed to load cog {cog_name}: {e}")
|
|
|
|
async def on_ready(self) -> None:
|
|
"""Called when the bot is ready."""
|
|
if self.user is None:
|
|
return
|
|
|
|
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 from config
|
|
activity = discord.Activity(
|
|
type=discord.ActivityType.watching,
|
|
name=settings.bot_status,
|
|
)
|
|
await self.change_presence(activity=activity)
|