Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 当command discord.py的参数不正确时,如何显示消息?_Python_Python 3.x_Bots_Discord.py_Discord.py Rewrite - Fatal编程技术网

Python 当command discord.py的参数不正确时,如何显示消息?

Python 当command discord.py的参数不正确时,如何显示消息?,python,python-3.x,bots,discord.py,discord.py-rewrite,Python,Python 3.x,Bots,Discord.py,Discord.py Rewrite,我正在创建一个discord bot,我想知道如何创建一个事件处理程序,当用户调用一个不存在的命令时,bot会发送一条消息说:“这不是一个有效的命令”。任何帮助都将不胜感激,谢谢 这应该可以做到: @机器人事件 命令上的异步定义错误(ctx,错误): 如果isinstance(错误,commands.CommandNotFound): 等待ctx.发送(“我猜是文字”) 这应该可以做到: @机器人事件 命令上的异步定义错误(ctx,错误): 如果isinstance(错误,commands.

我正在创建一个discord bot,我想知道如何创建一个事件处理程序,当用户调用一个不存在的命令时,bot会发送一条消息说:“这不是一个有效的命令”。任何帮助都将不胜感激,谢谢

这应该可以做到:


@机器人事件
命令上的异步定义错误(ctx,错误):
如果isinstance(错误,commands.CommandNotFound):
等待ctx.发送(“我猜是文字”)

这应该可以做到:


@机器人事件
命令上的异步定义错误(ctx,错误):
如果isinstance(错误,commands.CommandNotFound):
等待ctx.发送(“我猜是文字”)
类似于,只需将
return
替换为
wait ctx.send(…)
类似于,只需将
return
替换为
wait ctx.send(…)