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

Discord机器人运行失败求助:特权意图未启用报错

Discord机器人PrivilegedIntentsRequired错误修复

问题重现

你使用的代码:

import discord
from discord.ext import commands

client = commands.Bot(command_prefix="w!", intents=discord.Intents.all())

@client.event
async def on_ready():
    print("Success: Bot Is Logged In")

client.run("(not showing for obvious reasons)")

运行后触发的核心错误:

discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal.


解决方案

方案1:开启开发者门户中的特权意图

  1. 进入你的Discord机器人应用管理页面
  2. 切换到「Bot」标签页
  3. 找到「Privileged Gateway Intents」板块
  4. 启用需要的特权意图(通常是「Presence Intent」「Server Members Intent」,若需读取消息内容还需开启「Message Content Intent」)
  5. 保存设置后重启机器人

方案2:仅启用必要的非特权意图

如果你的机器人不需要特权功能,可修改代码只启用所需意图,避免请求特权权限:

import discord
from discord.ext import commands

# 初始化默认意图,启用消息内容意图以接收命令
intents = discord.Intents.default()
intents.message_content = True

client = commands.Bot(command_prefix="w!", intents=intents)

@client.event
async def on_ready():
    print("Success: Bot Is Logged In")

client.run("你的机器人令牌")

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.09 09:45:46