You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Discord Bot命令无响应:!balance命令无法触发排查求助

问题解决方法

核心原因

你自定义了on_message事件,但未在事件中调用await bot.process_commands(message),导致Discord.py的命令系统无法触发!balance这类前缀命令。

修复代码

修改on_message函数,在末尾添加命令处理逻辑:

@bot.event
async def on_message(message):
    msg = message.content.lower()
    if message.author == bot.user:
        return
    if msg.startswith('hello'):
      await message.channel.send('hello')
    # 让bot处理前缀命令
    await bot.process_commands(message)

原理说明

重写on_message事件会覆盖Discord.py默认的命令处理流程,必须显式调用process_commands,才能让bot在完成自定义消息处理后,继续解析并执行前缀命令。

额外检查项

  • 确认输入的命令前缀是!,没有拼写错误
  • 机器人已拥有频道内发送消息的权限(你已确认权限,可跳过)

内容的提问来源于stack exchange,提问作者skee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 15:27:33