python’s discord bot does not accept errors

This may not be the way you were handling the error, but it is one of the ways in case all else fails.

async def spoiler(ctx, *,text):
    author =
    author = author.mention
        await ctx.send("Spoiler from " + author + "\n" "||" + text + "||")
    except asyncio.TimeoutError:#using try and except for handling timeout error
        await ctx.send("Are you typing an essay or what?")      

async def spoiler_error(ctx, error):
    if isinstance(error, discord.errors.Forbidden):#permission error, may need to change
        await ctx.send("Grant me the permission to purge channels and try again.")
    if isinstance(error, discord.ext.commands.errors.MissingRequiredArgument):#if text is a missing required argument
        await ctx.send("You need to type the text you want to disclose!")

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top