【发布时间】:2022-07-20 00:57:50
【问题描述】:
我的简单测试代码
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
const { MessageEmbed, channels } = require('discord.js');
client.login('no peeking');
client.on('ready', readyUser);
function readyUser(){
console.log('Bot is ready and logged in');
}
client.on("messageCreate", (message) => {
const prefix = "!";
const args = message.content.substring(prefix.length).split(" ");
const command = args.shift().toLowerCase();
if (message.author.id != client.user.id) {
}
});
报错
TypeError: Cannot read properties of undefined (reading 'FLAGS')关于第 2 行。
根据我的发现,这可能是由于我的意图在 Discord 开发者门户中被禁用。即使我启用了它们,问题仍然存在。
【问题讨论】:
标签: node.js discord discord.js