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

运行node .启动Discord机器人时出现CLIENT_MISSING_INTENTS报错如何解决

问题原因

discord.js v13及更高版本强制要求开发者显式声明机器人需要使用的网关意图(Intents),用于控制机器人可以接收哪些Discord事件数据,你当前的代码初始化Client时没有传入任何Intents配置,所以触发了报错。

解决方案

步骤1:修改初始化Client的代码

根据你使用的discord.js版本选择对应写法:

若使用discord.js v14.x版本

const Discord = require('discord.js');
// 声明需要用到的Intents
const client = new Discord.Client({
  intents: [
    Discord.GatewayIntentBits.Guilds, // 基础服务器相关事件,必填
    Discord.GatewayIntentBits.GuildMessages, // 接收服务器消息事件,可选按需求加
    Discord.GatewayIntentBits.MessageContent, // 读取消息内容,可选按需求加
    Discord.GatewayIntentBits.GuildVoiceStates // 语音状态事件,音乐机器人必填
  ]
});

// 剩余原有代码无需修改
client.once('ready', () => {
    console.log ('Smegma Music is online!');
});

client.login('你的机器人Token');

若使用discord.js v13.x版本

const Discord = require('discord.js');
const client = new Discord.Client({
  intents: [
    Discord.Intents.FLAGS.GUILDS,
    Discord.Intents.FLAGS.GUILD_MESSAGES,
    Discord.Intents.FLAGS.MESSAGE_CONTENT,
    Discord.Intents.FLAGS.GUILD_VOICE_STATES
  ]
});

// 剩余原有代码无需修改

步骤2:开启Discord开发者后台特权权限

如果你用到了MESSAGE_CONTENT这类特权Intent,需要前往Discord开发者平台的对应机器人设置页,将Privileged Gateway Intents分类下的对应开关全部打开,否则机器人上线后无法正常接收对应事件。

补充说明

  • 可以根据机器人实际功能增减Intents列表,不需要的权限无需添加,减少不必要的事件接收
  • client.login方法传入的参数是机器人专属Token,不是ClientID,请注意不要填错参数
  • 修改完成后重新执行node .命令即可正常启动机器人

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.03 21:09:00