2.0 KiB
2.0 KiB
| id | type | title | tags | importance | confidence | created | updated | relations | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 4c3c7a86-46b6-4d42-a966-35071ba3bfe1 | fix | Fix: maintenance mode flag in /admin-maintenance (major-domo-v2 #28) |
|
0.6 | 0.8 | 2026-03-03T17:37:27.125744+00:00 | 2026-03-03T17:37:28.639130+00:00 |
|
Problem
/admin-maintenance in commands/admin/management.py showed a success embed but never set any state. No flag was set, no commands were blocked.
Root Cause
The command had a placeholder comment: "This would typically set a global flag or database value. For now, we'll just show the interface."
Solution
- Added
self.maintenance_mode: bool = FalsetoSBABot.__init__inbot.py - Registered a global
@self.tree.interaction_checkinsetup_hookthat intercepts every slash command interaction — returnsFalse(with ephemeral message) for non-admin users whenmaintenance_modeisTrue - Updated
admin_maintenancecommand to setself.bot.maintenance_mode = is_enablingand log the state change
Key Pattern
Discord.py's CommandTree.interaction_check is the correct hook for global command blocking. Register via @bot.tree.interaction_check inside setup_hook. Returning False prevents the command from executing.
Files Changed
bot.py— flag init + global tree checkcommands/admin/management.py— set flag + log state change
Notes
- Flag is in-memory only (resets on restart)
- Admins (guild
administratorpermission) bypass the block - 930 tests pass