diff --git a/bot.py b/bot.py index 5e002ca..213ae06 100644 --- a/bot.py +++ b/bot.py @@ -49,6 +49,8 @@ async def on_ready() -> None: await bot.tree.sync() # Sync global commands (might take up to 1 hour to reflect globally) except BadArgument as e: print(f'Error changing presence. Exception - {e}', flush=True) + except discord.HTTPException as e: + print(f"Failed to sync commands due to rate limiting: {e}") @bot.event async def on_member_update(before_update, user: discord.User): diff --git a/cogs/tasks.py b/cogs/tasks.py index 234bbf8..eed968e 100644 --- a/cogs/tasks.py +++ b/cogs/tasks.py @@ -108,11 +108,13 @@ async def sync_commands(self, override=False): return print("sync_commands started at " + str(datetime.now().isoformat()), flush=True) - - if guild: - await self.bot.tree.sync(guild=guild) # Sync commands to a specific guild for faster deployment - else: - await self.bot.tree.sync() # Sync global commands (might take up to 1 hour to reflect globally) + try: + if guild: + await self.bot.tree.sync(guild=guild) # Sync commands to a specific guild for faster deployment + else: + await self.bot.tree.sync() # Sync global commands (might take up to 1 hour to reflect globally) + except discord.HTTPException as e: + print(f"Failed to sync commands due to rate limiting: {e}") print("sync_commands finished at " + str(datetime.now().isoformat()), flush=True) except Exception as e: