【发布时间】:2021-12-30 09:25:50
【问题描述】:
我正在编写一个不和谐的机器人,但我无法摆脱这个错误。我已经看到了一些对其他人有用但对我不起作用的解决方案...我不断收到此错误:
throw new TypeError('CLIENT_MISSING_INTENTS'); ^ TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client. at Client._validateOptions (C:\Users\User\Desktop\discordBot\node_modules\discord.js\src\client\Client.js:548:13) at new Client (C:\Users\User\Desktop\discordBot\node_modules\discord.js\src\client\Client.js:76:10) at Object.<anonymous> (C:\Users\User\Desktop\discordBot\main.js:3:16) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:17:47 { [Symbol(code)]: 'CLIENT_MISSING_INTENTS' }
这是我的 main.js 代码:
const Discord = require('discord.js');
const client = new Discord.Client({ partials: ["MESSAGE", "CHANNEL", "REACTION" ]});
const prefix = '-';
const fs = require('fs');
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
client.on('ready', () => {
console.log('bot is online!');
});
client.on('message', message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if (command === 'reactionrole') {
client.commands.get('reactionrole').execute(message, args, Discord, client);
}
});
client.login('TOKEN');
有人知道我能做些什么吗?
【问题讨论】:
-
错误很明显,您的
client缺少intents。 discord.js.org/#/docs/main/stable/typedef/ClientOptions -
这能回答你的问题吗? How do I fix CLIENT_MISSING_INTENTS error?
标签: javascript discord discord.js