fix: implement actual maintenance mode flag in /admin-maintenance (#28)
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m17s

- Add `maintenance_mode: bool = False` flag to `SBABot.__init__`
- Register a global `@tree.interaction_check` that blocks non-admin users
  from all commands when maintenance mode is active
- Update `admin_maintenance` command to set `self.bot.maintenance_mode`
  and log the state change, replacing the no-op placeholder comment

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2026-03-03 11:36:50 -06:00
parent f7a65706a1
commit 35ad4e936b
2 changed files with 274 additions and 250 deletions

17
bot.py
View File

@ -81,11 +81,28 @@ class SBABot(commands.Bot):
)
self.logger = logging.getLogger("discord_bot_v2")
self.maintenance_mode: bool = False
async def setup_hook(self):
"""Called when the bot is starting up."""
self.logger.info("Setting up bot...")
@self.tree.interaction_check
async def maintenance_check(interaction: discord.Interaction) -> bool:
"""Block non-admin users when maintenance mode is enabled."""
if not self.maintenance_mode:
return True
if (
isinstance(interaction.user, discord.Member)
and interaction.user.guild_permissions.administrator
):
return True
await interaction.response.send_message(
"🔧 The bot is currently in maintenance mode. Please try again later.",
ephemeral=True,
)
return False
# Load command packages
await self._load_command_packages()

File diff suppressed because it is too large Load Diff