Ballsdex-Team / BallsDex-DiscordBot

Collect and exchange countryballs on Discord
Other
82 stars 140 forks source link

Handle permission errors correctly #351

Closed flaree closed 1 week ago

flaree commented 3 weeks ago

The generic the bot doesn't have permission to do something or you can not run this command checks need to be expanded upon and elaborated further.

bot has permissions check should return the missing permissions, some other stuff should fail more silently

imtherealF1 commented 3 weeks ago

would adding a check before running any command in bot.py, that would have something like permissions = channel.permissions missing_permissions = [] if not permissions.send_messages: missing_permissions.append('send messages') for every permission that is needed for the bot to run properly solve this issue?

flaree commented 3 weeks ago

would adding a check before running any command in bot.py, that would have something like

    permissions = channel.permissions

    missing_permissions = []

    if not permissions.send_messages:

        missing_permissions.append('send messages')

for every permission that is needed for the bot to run properly solve this issue?

No, you need to catch the error in the handler

This error is thrown specifically for BotMissingPermissions https://discordpy.readthedocs.io/en/stable/interactions/api.html?highlight=botmissingpermission#discord.app_commands.BotMissingPermissions which shows the permissions it requires