[英]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.我试图让我的机器人说出 cog 文件的错误处理程序中缺少什么参数。 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'
我查看了 API 并尝试了但我得到了错误, 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.注意:我在一个 cog 文件中写这个。
You can use error.param.name
您可以使用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}`")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.