fix: implement actual maintenance mode flag in /admin-maintenance (#28) #62
No reviewers
Labels
No Label
ai-changes-requested
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
in-next-release
status/in-progress
status/pr-open
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/major-domo-v2#62
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "ai/major-domo-v2-28"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes #28. The
/admin-maintenancecommand previously showed a success embed but never changed any state — no flag was set and no commands were blocked.Changes
bot.py: Addedself.maintenance_mode: bool = FalsetoSBABot.__init__. Registered a global@tree.interaction_checkinsetup_hookthat intercepts every slash command and blocks non-admin users with an ephemeral "maintenance mode" message when the flag is set.commands/admin/management.py: Updatedadmin_maintenanceto setself.bot.maintenance_mode = is_enablingand log the state change (user ID + enabled/disabled). Removed the no-op placeholder comment.Behaviour
🔧 The bot is currently in maintenance mode. Please try again later.(ephemeral). Admins (guildadministratorpermission) can still use all commands including the admin suite.Tests
All 930 tests pass. No existing tests were broken.
AI Code Review
Files Reviewed
bot.py(modified) — addedmaintenance_modeflag + globalinteraction_checkcommands/admin/management.py(modified) — wired flag intoadmin_maintenance, plus formatting cleanupFindings
Correctness
self.maintenance_mode: bool = Falseflag is correctly declared inSBABot.__init__, making it a proper instance attribute.@self.tree.interaction_checkinsidesetup_hookis idiomatic discord.py — it registers once at startup and the nested function capturesselfvia closure, so it always reads the live value ofself.maintenance_modeat interaction time. This is correct.isinstance(interaction.user, discord.Member) and interaction.user.guild_permissions.administrator) mirrors the existingAdminCommands.interaction_checkpattern exactly — consistent and correct.self.bot.maintenance_mode = is_enablinginadmin_maintenancecorrectly mutates the flag. Sincemodeis constrained byapp_commands.choicesto"on"/"off", themode.lower() == "on"test is safe.maintenance_checkis sent before returningFalse, which prevents the command from executing without leaving a dangling interaction. No double-response risk.Security
Style & Conventions
EmbedTemplate.create_base_embed()is correctly used for the maintenance embed title that contains a custom emoji (🔧), following the CLAUDE.md rule about not putting emoji inEmbedTemplate.success/error/warning/info()titles.self.loggeris used consistently per CLAUDE.md conventions.management.pydiff is mechanical reformatting (trailing commas, quote normalisation, line wrapping). No functional change there.Suggestions
self.bot.maintenance_modeis accessed fromAdminCommandswherebotis typed ascommands.Bot, which doesn't havemaintenance_mode. Works at runtime but would fail strict mypy. A typed bot reference would clean it up, but it's a pre-existing pattern in this codebase so not a blocker.interaction_check, coverage is acceptable for this change.Verdict: APPROVED
Clean, minimal implementation that directly fixes #28. The global
interaction_checkpattern is the correct discord.py approach, the admin bypass is consistent with existing permission logic, and no existing tests were broken.Automated review by Claude PR Reviewer
35ad4e936btoe3610e84ea