【发布时间】:2021-12-31 03:41:46
【问题描述】:
谁能告诉我我做错了什么?我收到一条错误消息“CLIENT_MISSING_INTENTS”。我不确定这意味着什么,我试图查找它,我发现的唯一一件事是安装我已经安装的 node.js,我需要将它安装到 Visual Studio Code 还是类似的东西?
index.js:
const bot = new Discord.Client({ disableEveryone: true });
const botconfig = require("./botconfig.json");
const fs = require("fs");
bot.commands = new Discord.Collection();
bot.aliases = new Discord.Collection();
// Read Commands Folder
fs.readdir("./commands/", (err, files) =>{
if(err) console.log(err);
let jsfile = files.filter(f => f.split(".").pop() === "js");
if(jsfile.length <= 0) {
console.log("Couldn't find any commands!")
return;
}
jsfile.forEach((f) => {
let props = require(`./commands/${f}`);
console.log(`${f} loaded!`);
bot.commands.set(props.help.name, props);
props.help.aliases.forEach(alias => {
bot.alias.set(alias, props.help.name);
})
})
})
// Bot Online Message And Activity Message
bot.on("ready", async () => {
console.log(`${bot.user.username} is online on ${bot.guilds.size} servers!`);
bot.user.setActivity(`with ${bot.guilds.size} servers!`)
})
bot.on("message", async message => {
// Check Channel Type
if(message.channel.type === "dm") return;
if(message.author.bot) return;
// Set Prefix
let prefix = botconfig.prefix;
// Check Prefix, Define Args & Command
if(!message.content.startsWith(prefix)) return;
let args = message.content.slice(prefix.length).trim().split(/ */g);
let cmd;
cmd = args.shift().toLowerCase();
let command;
let commandfile = bot.commands.get(cmd.slice(prefix.length));
if(commandfile) commandfile.run(bot, message, args);
// Run Commands
if(bot.commands.has(cmd)) {
command = bot.commands.get(cmd);
} else if (bot.aliases.has(cmd)) {
command = bot.commands.get(bot.aliases.get(cmd));
}
try {
command.run(bot, message, args);
} catch (e) {
return;
}
})
bot.login(botconfig.token)
【问题讨论】:
标签: node.js discord.js