fix: replace broken interaction_check decorator with MaintenanceAwareTree subclass #83
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#83
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/maintenance-mode-interaction-check"
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
@self.tree.interaction_checkinsidesetup_hook. This is not a valid pattern in discord.py —interaction_checkis an async method to be overridden on aCommandTreesubclass, not a decorator. The assignment was silently dropped, making maintenance mode a complete no-op and producing aRuntimeWarningabout an unawaited coroutine.MaintenanceAwareTree(discord.app_commands.CommandTree)that properly overridesinteraction_check: non-admins are blocked with an ephemeral message whenbot.maintenance_modeisTrue, administrators always pass through, and the check is a no-op when maintenance mode is off./admin-maintenancecommand now actually togglesbot.maintenance_modeinstead of just displaying a UI that did nothing.Changes
bot.py: AddMaintenanceAwareTreesubclass; passtree_cls=MaintenanceAwareTreetosuper().__init__(); addself.maintenance_mode: bool = Falsecommands/admin/management.py: Addself.bot.maintenance_mode = is_enablingtoadmin_maintenanceso the flag is actually settests/test_bot_maintenance_tree.py: 8 new unit tests covering all maintenance mode states, admin pass-through, non-Member DM context, and missing attribute fallbackTest plan
test_bot_maintenance_tree.pypass/admin-maintenance onblocks a non-admin user with an ephemeral message/admin-maintenance onstill allows admin commands through/admin-maintenance offrestores normal operationCloses #82