Search code examples
javascriptnode.jsdiscord.js

Intents keep giving me a error even though the intents code is a C&P from a working bot


I have tried this which is a copy of existing code from another one of my bots that works but when i run it i get a error saying "Intents is not defined"

const client = new Discord.Client({
  intents: [
    Intents.FLAGS.GUILDS,
    Intents.FLAGS.GUILD_MESSAGES,
    Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
    Intents.FLAGS.GUILD_PRESENCES,
  ],
})

Error:

ReferenceError: Intents is not defined

Solution

  • Simply, you should define the Intents by doing this:

    const { Client, Intents } = require('discord.js')
    

    Edit: You dont need to use Discord on discord.js v13 since its not needed, instead do it like this:

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