fix: implement actual maintenance mode flag in /admin-maintenance (#28)
- 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:
parent
bc8a256b14
commit
e3610e84ea
17
bot.py
17
bot.py
@ -80,11 +80,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
Loading…
Reference in New Issue
Block a user