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

求助:AttributeError: module 'discord.ext.commands' 无 'Client' 属性问题

解决AttributeError: module 'discord.ext.commands' has no attribute 'Client'错误
  • 错误根源:Client类属于discord核心模块,并非discord.ext.commands子模块的成员。discord.ext.commands模块专门用于开发命令式机器人,提供的是Bot或AutoShardedBot类。

  • 修复方法:

    1. 若仅需基础客户端(无命令功能),从discord模块导入Client:
      import discord
      client = discord.Client(intents=discord.Intents.default())
      
    2. 若要开发带命令系统的机器人,从discord.ext.commands导入Bot:
      from discord.ext import commands
      bot = commands.Bot(command_prefix='!', intents=discord.Intents.default())
      
  • 重要提示:使用Discord机器人必须配置正确的Intents,需在Discord开发者后台开启对应权限,并在代码中明确声明,否则机器人无法正常接收事件或消息。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.02 17:40:56