Reputation: 11
I am trying to create a discord bot and when i try to run "node ." in cmd after creating the code for the bot in visual studio code, I get an error message about the Client missing intents. Here is the error message.
C:\MusicBot>node .
C:\MusicBot\node_modules\discord.js\src\client\Client.js:544
throw new TypeError('CLIENT_MISSING_INTENTS');
^
TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client.
at Client._validateOptions (C:\MusicBot\node_modules\←[4mdiscord.js←[24m\src\client\Client.js:544:13)
at new Client (C:\MusicBot\node_modules\←[4mdiscord.js←[24m\src\client\Client.js:73:10)
at Object.<anonymous> (C:\MusicBot\main.js:3:16)
←[90m at Module._compile (internal/modules/cjs/loader.js:1072:14)←[39m
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)←[39m
←[90m at Module.load (internal/modules/cjs/loader.js:937:32)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:778:12)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)←[39m
←[90m at internal/main/run_main_module.js:17:47←[39m {
[←[32mSymbol(code)←[39m]: ←[32m'CLIENT_MISSING_INTENTS'←[39m
}
My code is as follows: (the 'x' are the bots clientID)
const Discord = require('discord.js');
const client = new Discord.Client();
client.once('ready', () => {
console.log ('Smegma Music is online!');
});
client.login('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); //at end
Upvotes: 0
Views: 159
Reputation: 670
It's a new issue that was not in discord v12
you could use this
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
OR
change discord to version 12
Upvotes: 1