Coleman Ethington
Coleman Ethington

Reputation: 162

Trying to make bot say what argument is missing for an error handler

I'm trying to make my bot say what argument was missing in an error handler in a cog file. I looked at the API and tried but i get the error, File "/home/runner/Ultimate-Bot/cogs/Commands.py", line 35, in on_command_error missing_argument = error.missing_argument AttributeError: 'MissingRequiredArgument' object has no attribute 'missing_argument'

Here is my code that I have,

if isinstance(error, commands.MissingRequiredArgument):
        missing_argument = error.missing_argument
        await ctx.send(f"{ctx.author.mention}, Sorry, you forgot to type an important argument! `Missing Argument: {missing_argument}`")

NOTE: I am writing this in a cog file.

Upvotes: 0

Views: 46

Answers (1)

Ay355
Ay355

Reputation: 434

You can use error.param.name

Example:

if isinstance(error, commands.MissingRequiredArgument):
    await ctx.send(f"{ctx.author.mention}, Sorry, you forgot to type an important argument! `Missing Argument: {error.param.name}`")

Upvotes: 2

Related Questions