claude-memory/graph/fixes/fix-maintenance-mode-flag-in-admin-maintenance-major-domo-v2-4c3c7a.md

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)
major-domo
discord
python
discord.py
bot
maintenance-mode
tree-interaction-check
0.6 0.8 2026-03-03T17:37:27.125744+00:00 2026-03-03T17:37:28.639130+00:00
target type direction strength edge_id
58d7a0e2-16b1-41fa-a31c-d74442d8b08e RELATED_TO outgoing 0.71 9a8a7d1e-08d1-4ce4-8609-0e0614d2529b
target type direction strength edge_id
4edbf516-fe92-4e70-995a-266fe9f183ee RELATED_TO outgoing 0.7 758f2105-5232-489b-aba5-36c7b05b80cb
target type direction strength edge_id
62ee21e8-2b56-4d38-a73d-47e2724f08c6 BUILDS_ON outgoing 0.67 7e3aa1c6-72bf-42f9-898a-6bafdccdab26

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

  1. Added self.maintenance_mode: bool = False to SBABot.__init__ in bot.py
  2. Registered a global @self.tree.interaction_check in setup_hook that intercepts every slash command interaction — returns False (with ephemeral message) for non-admin users when maintenance_mode is True
  3. Updated admin_maintenance command to set self.bot.maintenance_mode = is_enabling and 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 check
  • commands/admin/management.py — set flag + log state change

Notes

  • Flag is in-memory only (resets on restart)
  • Admins (guild administrator permission) bypass the block
  • 930 tests pass