简体   繁体   English

试图让机器人说出错误处理程序缺少什么参数

[英]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.

相关问题 如何让discord bot说出接下来播放的歌曲 - How to make discord bot say what song is being played next 试图让 discord.py 机器人在提到它时说些什么,没有回应 - Trying to make discord.py bot say something when its gets mentioned, doesnt respond 试图使函数减去一个定义的数字一个错误“缺少 1 个必需的位置参数” - Trying to make function subtract a defined number by one error "missing 1 required positional argument" 如何让 discord.py 机器人说出服务器使用的前缀是什么? - How to make discord.py bot say what prefix the server is using? 让 discord 机器人在语音频道上说些什么 - Make a discord bot say something on voice channel 尝试在 python 上执行缺少 discord 机器人所需权限的错误消息 - Trying to do an error message of missing required permission for discord bot on python 尝试制作条形图,bar() 缺少 1 个必需的位置参数:'height' - Trying to make a barchart, bar() missing 1 required positional argument: 'height' 试图制作一个whatsapp bot - Trying to make a whatsapp bot 试图制作一个服务器机器人,但日期时间有问题,我不明白它是什么 - trying to make a server bot but there is a problem with datetime and i dont understand what it is 缺少 1 个必需的位置参数:'source',试图让 discord 机器人播放暂停的音频 - missing 1 required positional argument: 'source', trying to get discord bot to play paused audio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM