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

在终端运行Discord Bot时遭遇DisallowedIntents问题

解决Discord机器人DisallowedIntents错误

问题原因

你代码里用到的GuildMembers和MessageContent属于Discord的特权网关意图,这类意图默认处于关闭状态,必须在Discord开发者后台手动开启,否则会触发DisallowedIntents报错。

解决步骤

  • 登录Discord开发者平台,找到你的机器人应用
  • 进入「Bot」页面,滚动到「Privileged Gateway Intents」板块
  • 开启「Server Members Intent」和「Message Content Intent」两个开关
  • 重启机器人进程,让新的权限设置生效

代码确认

你的代码本身的意图配置没有问题,无需修改:

const { Client, GatewayIntentBits } = require("discord.js");

const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent,
    GatewayIntentBits.GuildMembers
  ],
});

client.login("TOKEN");

注:Guilds和GuildMessages属于普通意图,无需额外开启。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.19 18:45:40