为什么当我试图让我的discord机器人在线时,我总是收到这个错误



我尝试制作一个discordbot,并在键入node时执行了第一步和命令提示符。显示如下:

TypeError[CLIENT_MISSING_INTENTS]:必须为客户端提供有效的意图。在客户处_validateOptions(C:\Users\giann\Desktop\BWKS\node_modules\discord.js\src\client\client.js:548:13(在新客户端(C:\Users\giann\Desktop\BWKS\node_modules\discord.js\src\Client\Client.js:76:10(在对象处。(C:\Users\giann\Desktop\BWKS\main.js:2:16(在模块中_compile(节点:internal/modules/cjs/loader:1103:14(在对象处。模块_扩展。。js(节点:internal/modules/cjs/loader:1155:10(在Module.load(节点:internal/modules/cjs/loader:981:32(在Function。模块_加载(节点:internal/modules/cjs/loader:822:12(在Function.executeUserEntryPoint[作为runMain](节点:internal/modules/run_main:77:12(在节点:internal/main/run_main_module:17:47{[符号(代码(]:'CLIENT_MISSING_INTENTS'}

我几乎什么都试过了,但这个错误总是出现。

代码:

const client = new Discord.Client();

client.once('ready', () => {
console.log('Ready')
});
client.login('the token');

Discord需要知道您想要使用什么意图。因此,要修复您的代码,请使用:

const client = new Discord.Client({ intents: [<ARRAY WITH ALL INTENTS>] });

client.once('ready', () => {
console.log('Ready')
});
client.login('the token');

您可以使用字符串"GUILDS"或使用属性Intents.FLAGS.GUILDS在数组中添加意图

所有意图的列表可以在这里找到:https://discord.js.org/#/docs/discord.js/stable/class/Intents

相关内容

最新更新