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

执行node main.js后Discord Bot无法上线的故障排查求助

解决Discord Bot启动时的TypeError错误

错误根源:你使用的discord.js版本是v14.3.0,该版本已移除Discord.Intents.FLAGS写法,改用GatewayIntentBits定义网关意图,因此出现读取FLAGS时未定义的报错。

修复步骤:

  • 修改main.js里的意图定义代码,将Discord.Intents.FLAGS替换为Discord.GatewayIntentBits
  • 意图名称保持不变,仅归属对象变更

修改后的完整main.js代码:

const Discord = require('discord.js');

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

client.once('ready', () => { 
    console.log('GhxstedCloudz is online');
});

client.login('my bot token');

额外注意:若你的Bot需要读取消息内容,需在Discord开发者门户的Bot设置中开启消息内容特权(Message Content Intent),否则无法获取消息内容。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.19 16:25:55