gpt4 book ai didi

javascript - 如何修复 CLIENT_MISSING_INTENTS 错误?

转载 作者:行者123 更新时间:2023-12-04 07:17:11 27 4
gpt4 key购买 nike

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

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');

这是我得到的错误:
enter image description here

最佳答案

您需要使用 gateway intents 指定希望机器人接收的事件.
代替const client = new Discord.Client();利用const client = new Discord.Client({ intents: [Enter intents here] })例如const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] })这是另一个有用的链接:https://discord.com/developers/docs/topics/gateway

关于javascript - 如何修复 CLIENT_MISSING_INTENTS 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68694195/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com