discord.py problems with if not arg (clear command)

后端 未结 1 850
离开以前
离开以前 2021-01-26 06:59

I have a problem with if not arg (I skip it directly) and I understand that putting arg: int creates problems for me. Do you know a solution? I tried w

1条回答
  •  失恋的感觉
    2021-01-26 07:10

    If you don't specify a required argument while invoking a command, it will cause a MissingRequiredArgument error and it won't execute your function. You just have to add this error in your clear_error function like so:

    @clear.error
    async def clear_error(ctx, error):
        embed = discord.Embed(color=0xe74c3c)
        if isinstance(error, commands.CheckFailure):
            embed.set_author(
                name="You're not authorized to delete messages!",
                icon_url='your image'
            )  
        elif isinstance(error, commands.MissingRequiredArgument):
            embed.set_author(
                name="You need to specify how many messages you want to delete!",
                icon_url='your image'
            )
        await ctx.send(embed=embed, delete_after=10.0)
    

    Also, you won't need your if not arg anymore

    0 讨论(0)
提交回复
热议问题