Persist bot mode across restarts via database

Adds a BotSettings key-value table. The active mode is saved
when changed via /bcs-mode and restored on startup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-23 09:26:00 -05:00
parent 622f0a325b
commit 6e1a73847d
3 changed files with 71 additions and 0 deletions

8
bot.py
View File

@@ -104,6 +104,14 @@ class BCSBot(commands.Bot):
loaded = self.drama_tracker.load_user_states(states)
logger.info("Loaded %d user states from database.", loaded)
# Restore saved mode
saved_mode = await self.db.load_setting("current_mode")
if saved_mode:
modes = self.config.get("modes", {})
if saved_mode in modes and isinstance(modes.get(saved_mode), dict):
self.current_mode = saved_mode
logger.info("Restored saved mode: %s", saved_mode)
await self.load_extension("cogs.sentiment")
await self.load_extension("cogs.commands")
await self.load_extension("cogs.chat")