python - 删除“找不到命令”错误 discord.py
问题描述
在 discord.py rewrite bot 中,如果有人键入 bots 前缀,然后是其后的任何文本,如果没有找到该文本作为命令,您将得到
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "sd" is not found
有没有办法阻止机器人记录这个?
解决方案
编写一个on_command_error
错误处理程序,检查错误是否是 的实例CommandNotFound
,如果是则忽略它
from discord.ext.commands import CommandNotFound
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, CommandNotFound):
return
raise error
推荐阅读
- react-native - 使用 AES128-ECB 加密十六进制并在 javascript/node 中维护大端
- angular - 角嵌套路由器插座子项在路由器动画完成之前消失
- r - SpadeR::SimilarityMult Abundance based dissimilarity ERROR
- scrapy - 从scrapy计算刮掉的项目
- user-interface - 谷歌表格脚本从编辑权限中删除“制作副本”或“下载”?
- vue.js - 如何构建 vuejs 动态组件?
- python - 根据另一列的条件计算价格变化和价格的累积百分比变化
- python - Keras自动编码器的输入和输出层不匹配,无法运行模型
- php - 试图在laravel中获取非对象问题的属性
- scala - 为什么我在 Spark 中使用 combineByKey 的字数是值总和的两倍?