fix(ci): ruff format bot.py
All checks were successful
ci / ci (push) Successful in 44s
ci / ci (pull_request) Successful in 45s
deploy / deploy (push) Successful in 37s

This commit is contained in:
Mathis 2026-09-20 18:56:06 +02:00
parent a32dc723e9
commit 4d2be145aa

19
bot.py
View file

@ -28,6 +28,8 @@ class VisionBot(commands.Bot):
await self.load_extension("commandes.hello") await self.load_extension("commandes.hello")
await self.load_extension("commandes.modmail") await self.load_extension("commandes.modmail")
self.tree.on_error = self.on_app_command_error
if config.DEV and DEV_GUILD_IDS: if config.DEV and DEV_GUILD_IDS:
logger.info(f"Mode DEV — sync des commands sur les guilds: {DEV_GUILD_IDS}") logger.info(f"Mode DEV — sync des commands sur les guilds: {DEV_GUILD_IDS}")
for guild_id in DEV_GUILD_IDS: for guild_id in DEV_GUILD_IDS:
@ -37,15 +39,24 @@ class VisionBot(commands.Bot):
await self.tree.sync(guild=guild) await self.tree.sync(guild=guild)
logger.info(f" ✓ Sync guild {guild_id}") logger.info(f" ✓ Sync guild {guild_id}")
except discord.HTTPException as e: except discord.HTTPException as e:
logger.warning( logger.warning(f" ✗ Sync guild {guild_id} impossible ({e}). Le bot est-il invité sur ce serveur ?")
f" ✗ Sync guild {guild_id} impossible ({e}). "
f"Le bot est-il invité sur ce serveur ?"
)
else: else:
logger.info("Mode PROD — sync global des slash commands...") logger.info("Mode PROD — sync global des slash commands...")
await self.tree.sync() await self.tree.sync()
logger.info("Slash commands synchronisées (global)") logger.info("Slash commands synchronisées (global)")
async def on_app_command_error(self, interaction: discord.Interaction, error: discord.app_commands.AppCommandError):
logger.error(
f"Erreur commande /{interaction.command.name if interaction.command else '?'} : {error}", exc_info=error
)
try:
if interaction.response.is_done():
await interaction.followup.send(f"Erreur : `{error}`", ephemeral=True)
else:
await interaction.response.send_message(f"Erreur : `{error}`", ephemeral=True)
except discord.HTTPException:
pass
async def on_ready(self): async def on_ready(self):
instance = "DEV" if config.DEV else "PROD" instance = "DEV" if config.DEV else "PROD"
logger.info(f"[{instance}] Connecté en tant que {self.user} (ID: {self.user.id})") logger.info(f"[{instance}] Connecté en tant que {self.user} (ID: {self.user.id})")