fix(bot): guild sync dev (discord.Object) + tolerant des echecs de sync
Some checks failed
ci / ci (push) Failing after 44s
ci / ci (pull_request) Failing after 42s

This commit is contained in:
Mathis 2026-09-19 16:47:04 +02:00
parent 21123b182f
commit a32dc723e9
2 changed files with 11 additions and 3 deletions

View file

@ -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

13
bot.py
View file

@ -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()