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

Python Discord Bot命令无响应问题求助

Discord Bot !test命令无响应问题排查
  • 库冲突导致的导入异常
    你同时安装了discord.py和py-cord,这两个库共享discord命名空间,会导致Bot类的实现冲突,命令无法被正确注册或触发。
    解决:卸载其中一个库,比如保留py-cord的话执行:

    pip uninstall discord.py
    

    或者保留discord.py则卸载py-cord:

    pip uninstall py-cord
    
  • 未开启消息内容意图
    Discord的新规则要求bot必须启用消息内容意图才能读取用户发送的命令。
    解决:修改代码添加意图配置:

    import discord
    from discord.ext import commands
    from discord.ui import Select,View
    
    # 添加意图配置
    intents = discord.Intents.default()
    intents.message_content = True
    bot = commands.Bot(command_prefix="!", intents=intents)
    
    @bot.event
    async def on_ready():
        print('Logged in!')
    
    @bot.command()
    async def test(ctx):
        await ctx.send("hello")
    
    bot.run("token here")
    

    同时登录Discord开发者门户,找到你的Bot应用,在「Bot」页面开启「Message Content Intent」开关。

  • Bot权限不足
    检查Bot在服务器中的权限,确保它拥有「查看频道」「发送消息」「读取消息历史」等必要权限,可临时赋予管理员权限测试是否是权限问题。

  • 命令触发格式错误
    确认发送命令时输入的是!test,没有多余空格或字符,且Bot所在频道能正常接收消息。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.04 15:25:33