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.
JavaScript
x
18
18
1
C:MusicBot>node .
2
C:MusicBotnode_modulesdiscord.jssrcclientClient.js:544
3
throw new TypeError('CLIENT_MISSING_INTENTS');
4
^
5
6
TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client.
7
at Client._validateOptions (C:MusicBotnode_modules←[4mdiscord.js←[24msrcclientClient.js:544:13)
8
at new Client (C:MusicBotnode_modules←[4mdiscord.js←[24msrcclientClient.js:73:10)
9
at Object.<anonymous> (C:MusicBotmain.js:3:16)
10
←[90m at Module._compile (internal/modules/cjs/loader.js:1072:14)←[39m
11
←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)←[39m
12
←[90m at Module.load (internal/modules/cjs/loader.js:937:32)←[39m
13
←[90m at Function.Module._load (internal/modules/cjs/loader.js:778:12)←[39m
14
←[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)←[39m
15
←[90m at internal/main/run_main_module.js:17:47←[39m {
16
[←[32mSymbol(code)←[39m]: ←[32m'CLIENT_MISSING_INTENTS'←[39m
17
}
18
My code is as follows: (the ‘x’ are the bots clientID)
JavaScript
1
11
11
1
const Discord = require('discord.js');
2
3
const client = new Discord.Client();
4
5
client.once('ready', () => {
6
console.log ('Smegma Music is online!');
7
});
8
9
10
client.login('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); //at end
11
Advertisement
Answer
It’s a new issue that was not in discord v12
you could use this
JavaScript
1
4
1
const { Client, Intents } = require('discord.js');
2
3
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
4
OR
change discord to version 12