From 008d6be86c90c21bb4c702f0e60cc6938bcd76a3 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Fri, 20 Mar 2026 10:32:52 -0500 Subject: [PATCH] cleanup: remove dead maintenance mode artifacts in bot.py (#104) Closes #104 - Remove duplicate `self.maintenance_mode: bool = False` assignment (merge artifact from PR #83) - Delete dead `@self.tree.interaction_check` block in `setup_hook` that generated a RuntimeWarning at startup; `MaintenanceAwareTree.interaction_check()` already handles this correctly via the `tree_cls=MaintenanceAwareTree` kwarg Co-Authored-By: Claude Sonnet 4.6 --- bot.py | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/bot.py b/bot.py index 3500209..735e875 100644 --- a/bot.py +++ b/bot.py @@ -42,7 +42,9 @@ def setup_logging(): # JSON file handler - structured logging for monitoring and analysis json_handler = RotatingFileHandler( - "logs/discord_bot_v2.json", maxBytes=5 * 1024 * 1024, backupCount=5 # 5MB + "logs/discord_bot_v2.json", + maxBytes=5 * 1024 * 1024, + backupCount=5, # 5MB ) json_handler.setFormatter(JSONFormatter()) logger.addHandler(json_handler) @@ -120,28 +122,11 @@ class SBABot(commands.Bot): self.maintenance_mode: bool = False 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() @@ -443,7 +428,9 @@ async def health_command(interaction: discord.Interaction): embed.add_field(name="Bot Status", value="✅ Online", inline=True) embed.add_field(name="API Status", value=api_status, inline=True) embed.add_field(name="Guilds", value=str(guild_count), inline=True) - embed.add_field(name="Latency", value=f"{bot.latency*1000:.1f}ms", inline=True) + embed.add_field( + name="Latency", value=f"{bot.latency * 1000:.1f}ms", inline=True + ) if bot.user: embed.set_footer(