cleanup: remove dead maintenance mode artifacts in bot.py (#104)
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m6s
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m6s
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 <noreply@anthropic.com>
This commit is contained in:
parent
6c49233392
commit
008d6be86c
25
bot.py
25
bot.py
@ -42,7 +42,9 @@ def setup_logging():
|
|||||||
|
|
||||||
# JSON file handler - structured logging for monitoring and analysis
|
# JSON file handler - structured logging for monitoring and analysis
|
||||||
json_handler = RotatingFileHandler(
|
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())
|
json_handler.setFormatter(JSONFormatter())
|
||||||
logger.addHandler(json_handler)
|
logger.addHandler(json_handler)
|
||||||
@ -120,28 +122,11 @@ class SBABot(commands.Bot):
|
|||||||
|
|
||||||
self.maintenance_mode: bool = False
|
self.maintenance_mode: bool = False
|
||||||
self.logger = logging.getLogger("discord_bot_v2")
|
self.logger = logging.getLogger("discord_bot_v2")
|
||||||
self.maintenance_mode: bool = False
|
|
||||||
|
|
||||||
async def setup_hook(self):
|
async def setup_hook(self):
|
||||||
"""Called when the bot is starting up."""
|
"""Called when the bot is starting up."""
|
||||||
self.logger.info("Setting up bot...")
|
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
|
# Load command packages
|
||||||
await self._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="Bot Status", value="✅ Online", inline=True)
|
||||||
embed.add_field(name="API Status", value=api_status, 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="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:
|
if bot.user:
|
||||||
embed.set_footer(
|
embed.set_footer(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user