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

运行Telegram-Discord桥接脚本出现CLIENT_MISSING_INTENTS错误如何解决

错误诱因

你使用的discord.js为v13及以上版本,该版本起Discord强制要求所有机器人必须显式声明网关意图(Intents),用于指定机器人的接口访问范围、可接收的事件类型,你当前代码初始化Discord客户端时未传入任何合法意图配置,因此触发该错误。

修复步骤
  • 第一步:修改Discord客户端初始化配置,补充所需意图
    你当前的桥接服务仅需要访问Discord服务器频道、发送频道消息,只需开启Guilds意图即可,将原代码中:
const bot2 = new Discord.Client();

替换为:

const bot2 = new Discord.Client({
  intents: [
    // discord.js v14 版本用下面这行
    Discord.IntentsBitField.Flags.Guilds
    // 如果是discord.js v13 版本,注释上面一行,用下面这行
    // Discord.Intents.FLAGS.GUILDS
  ]
});
  • 第二步:修复缓存访问语法
    discord.js v13及以上版本所有缓存数据都需要通过.cache属性访问,将原代码中:
bot2.channels.get(channelid).send("[Telegram] **" + msg.from.first_name + " (@" + msg.from.username + "):** " + msg.text);

替换为:

bot2.channels.cache.get(channelid).send("[Telegram] **" + msg.from.first_name + " (@" + msg.from.username + "):** " + msg.text);

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.05 18:48:02