Search code examples
pythonexceptiondiscorddiscord.py

discord.py exception for when bot doesn't have permission


async def on_command_error(ctx, error):
    if isinstance(error, BotMissingPermissions):
        await ctx.send("I dont have the permission to do that")``

does not work and I'm guessing it's because I'm actually getting error discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions but I cannot find how to except it

I'm also doing it globally not per command


Solution

  • @bot.event
    async def on_command_error(ctx, error):
        if isinstance(error, discord.Forbidden):
            await ctx.send("I dont have the permission to do that")