So, I just started coding a bot in Javascript, something I have never worked with before. I am following the exact steps I see in the video, although, when I run node . in the terminal, I get an error:
TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client.
at Client._validateOptions (C:\Users\Acer\Desktop\Discord\Bots\SE\node_modules\discord.js\src\client\Client.js:548:13)
at new Client (C:\Users\Acer\Desktop\Discord\Bots\SE\node_modules\discord.js\src\client\Client.js:76:10)
at Object.<anonymous> (C:\Users\Acer\Desktop\Discord\Bots\SE\index.js:2:13)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159: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:77:12)
at node:internal/main/run_main_module:17:47 {
[Symbol(code)]: 'CLIENT_MISSING_INTENTS'
}
This is my code:
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES] });
const Discord = require('discord.js');
const bot = new Discord.Client();
const token = 'i aint showing you my token';
const PREFIX = '';
bot.on('ready', () => {
console.log('SEBot is online.')
})
bot.login(token)
I don't understand what the problem is, and some help would really work out. Thanks.
So first of all, you already initialized your client with
const client = new Client({ intents: [Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES] });
Then you initialized another one, which is useless now. You should remove
const Discord = require('discord.js');
const bot = new Discord.Client();
also your client (which has valid intents) should be the one that you call the .on() function, so switch bot.on() and bot.login() to client.on and client.login