From a32dc723e985cf3c0a0838a45af446f3d23ca2d5 Mon Sep 17 00:00:00 2001 From: Mathis Date: Sat, 19 Sep 2026 16:47:04 +0200 Subject: [PATCH] fix(bot): guild sync dev (discord.Object) + tolerant des echecs de sync --- .env.example | 1 + bot.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index cbb945a..a5c6b2b 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,7 @@ DISCORD_TOKEN=your_bot_token_here APPLICATION_ID=your_application_id_here DEV=1 +DEV_GUILD_IDS=optional_test_guild_id FORGEJO_URL=https://your-forgejo-instance.com FORGEJO_OWNER=your_forgejo_owner FORGEJO_REPO=your_repo_name diff --git a/bot.py b/bot.py index 25b2592..591d5cd 100644 --- a/bot.py +++ b/bot.py @@ -31,9 +31,16 @@ class VisionBot(commands.Bot): if config.DEV and DEV_GUILD_IDS: logger.info(f"Mode DEV — sync des commands sur les guilds: {DEV_GUILD_IDS}") for guild_id in DEV_GUILD_IDS: - self.tree.copy_global_to(guild=guild_id) - await self.tree.sync(guild=guild_id) - logger.info(f" ✓ Sync guild {guild_id}") + guild = discord.Object(id=guild_id) + self.tree.copy_global_to(guild=guild) + try: + await self.tree.sync(guild=guild) + logger.info(f" ✓ Sync guild {guild_id}") + except discord.HTTPException as e: + logger.warning( + f" ✗ Sync guild {guild_id} impossible ({e}). " + f"Le bot est-il invité sur ce serveur ?" + ) else: logger.info("Mode PROD — sync global des slash commands...") await self.tree.sync()