python - 如果 client.event 在脚本中,Python Discord Bot,client.command 将停止工作
问题描述
我在 python 中制作了一个不和谐的机器人,但每次我将它添加到我的脚本时,命令都会停止工作:
@client.event
async def on_message(message):
message=message.content
print(message)
有人知道,如何解决?提前致谢!!!!
解决方案
将此行添加到您的代码中:
await bot.process_commands(message)
例如:
@bot.event
async def on_message(message):
# do some extra stuff here
await bot.process_commands(message)
不要在“齿轮”中使用。
推荐阅读
- javascript - 在遵守 Eslint no-param-reassign 的同时从对象中删除
- django - 在 django 上覆盖不同表中的字段
- java - 如何在 Mulesoft 4 自定义连接器中使用非阻塞 HTTP 请求
- reactjs - 如何在 React 中使用 Map 遍历复杂对象
- amazon-alb - Amazon ALB:如何在没有自定义域的情况下设置 HTTPS 侦听器
- javascript - 'string | 类型不存在属性'substr' 细绳[]'
- php - 您可以将 acf 子字段循环到 html 标记中吗?
- php - 少数参数的依赖注入
- angularjs - 内容下载(CSS、JS 等)花费太多时间,导致加载速度太慢
- java - OutOfMemory 错误:超出 GC 开销限制 - 休眠