【发布时间】:2021-09-18 04:09:26
【问题描述】:
我正在使用 Discord.js V13,当我尝试运行机器人时,我每次都会收到此错误。
主文件:
const { Discord, Intents } = require('discord.js');
const client = new Discord.Client({
partials: ["CHANNEL","MESSAGE","REACTION"],
intents: [Intents.ALL]
});
错误:
const client = new Discord.Client({
^
TypeError: Cannot read properties of undefined (reading 'Client')
这里的解决方案是我不能从自身解构库,我的错误是我只需要放置我的机器人需要的意图。
我的解决方案:
const Discord = require('discord.js');
const client = new Discord.Client({
partials: ["CHANNEL","MESSAGE","REACTION"],
intents: [
Discord.Intents.FLAGS.GUILDS, // <--line 5 here
Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Discord.Intents.FLAGS.GUILD_MESSAGES,
Discord.Intents.FLAGS.GUILD_INVITES,
Discord.Intents.FLAGS.GUILD_MEMBERS,
Discord.Intents.FLAGS.GUILD_PRESENCES
]
});
【问题讨论】:
-
你检查过the docs吗?它有一个让客户就位的例子。
标签: javascript node.js discord.js