Search code examples
javascriptdiscorddiscord.jsbots

Coding a discord bot on discord.js and i keep getting the error "TypeError [ClientMissingIntents]: Valid intents must be provided for the Client."


when I try to run the code it gives me the error "TypeError [ClientMissingIntents]: Valid intents must be provided for the Client.". I tried using node . and node main.js to run it. I followed a yt tutorial and it looks like it should work.

Here is my code:

const Discord = require('discord.js');

const client = new Discord.Client();

const token = 'TOKEN HERE'

client.once('ready', () => {
    console.log('GamrBot1.0 is online');
});

client.login(token);

Solution

  • From discord.js v13, you need Intents when you declare your client. You can add them by doing this:

    const { Client, Intents } = require('discord.js')
    const client = new Client({
        intents: [
            Intents.FLAGS.GUILDS,
            // ...
        ]
    })
    

    For more information, I'd suggest you go here => Gateway Intents