Skip to content

Commit

Permalink
Merge pull request #94 from Vatsim-Scandinavia/feature/training-roles
Browse files Browse the repository at this point in the history
Error catching
  • Loading branch information
Marko259 authored Sep 27, 2024
2 parents e653fb6 + 862fb8f commit cd59fa0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
12 changes: 7 additions & 5 deletions cogs/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit cd59fa0

Please sign in to comment.