我开始学习 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');
这是我得到的错误:
原文由 NewJs 发布,翻译遵循 CC BY-SA 4.0 许可协议
您需要使用 网关意图 指定您希望机器人接收的事件。
代替
const client = new Discord.Client();
利用
const client = new Discord.Client({ intents: [Enter intents here] })
例如
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] })
这是另一个有用的页面: 网关
npm install node@16
在外壳中。