cleanup: remove dead maintenance mode artifacts in bot.py (#104) #105
25
bot.py
25
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(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user