Skip to content

Commit

Permalink
Added debug checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Marko259 committed Sep 27, 2024
1 parent 58c75ae commit d44c6f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ async def on_ready() -> None:
try:
await bot.change_presence(activity=config.activity(), status=config.status())
await bot.tree.sync() # Sync global commands (might take up to 1 hour to reflect globally)

guild = bot.get_guild(GUILD_ID)
bot_member = guild.get_member(bot.user.id)

if bot_member.guild_permissions.administrator or bot_member.guild_permissions.manage_guild:
await print("Bot has the required permissions to sync commands.", flush=True)
else:
await print("Bot is missing required permissions.", flush=True)

except BadArgument as e:
print(f'Error changing presence. Exception - {e}', flush=True)
except discord.HTTPException as e:
Expand Down
6 changes: 6 additions & 0 deletions cogs/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ async def user_check(self, interaction: discord.Integration):
async def sync_commands(self, override=False):
now = datetime.now().isoformat()
guild = discord.Object(id=GUILD_ID)
bot_member = guild.get_member(self.bot.user.id)

try:
if DEBUG == True and override == False:
Expand All @@ -113,6 +114,11 @@ async def sync_commands(self, override=False):
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)

if bot_member.guild_permissions.administrator or bot_member.guild_permissions.manage_guild:
await print("Bot has the required permissions to sync commands.", flush=True)
else:
await print("Bot is missing required permissions.", flush=True)
except discord.HTTPException as e:
print(f"Failed to sync commands due to rate limiting: {e}")

Expand Down

0 comments on commit d44c6f9

Please sign in to comment.