如何修复 CLIENT_MISSING_INTENTS 错误? [英] How do I fix CLIENT_MISSING_INTENTS error?

查看:27
本文介绍了如何修复 CLIENT_MISSING_INTENTS 错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始学习 discord.js 但现在我正面临这个问题.我尝试了一些谷歌搜索,但无法修复它.

I started learning about discord.js but now I am facing this issue. I tried some googling but couldn't manage to fix it.

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

// using Intents class
const client = new Discord.Client();

client.on('message', (msg) => {
  // Send back a reply when the specific command has been written by a user.
  if (msg.content === '!hello') {
    msg.reply('Hello World!');
  }
});

client.login('my_token');

这是我得到的错误:

推荐答案

您需要使用 网关意图.

代替

const client = new Discord.Client();

使用

const client = new Discord.Client({ intents: [在此处输入意图] })

例如

const client = new Discord.Client({ intents: [GUILDS", GUILD_MESSAGES"] })

这是另一个有用的链接:https://discord.com/developers/docs/topics/gateway

Here's another useful link: https://discord.com/developers/docs/topics/gateway

这篇关于如何修复 CLIENT_MISSING_INTENTS 错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆