Search code examples
javascriptnode.jsdiscorddiscord.js

Problem with Intents updating discord.js version 14


i am having a problem when i want to update to discord.js version 14 this is my discord.js client code

const { Client, GatewayIntentBits } = require('discord.js')
const client = new Client({
    intents: [
        GatewayIntentBits.FLAGS.GUILDS,
        GatewayIntentBits.FLAGS.GUILD_MEMBERS,
        GatewayIntentBits.FLAGS.GUILD_BANS,
        GatewayIntentBits.FLAGS.GUILD_INTEGRATIONS,
        GatewayIntentBits.FLAGS.GUILD_WEBHOOKS,
        GatewayIntentBits.FLAGS.GUILD_INVITES,
        GatewayIntentBits.FLAGS.GUILD_VOICE_STATES,
        GatewayIntentBits.FLAGS.GUILD_PRESENCES,
        GatewayIntentBits.FLAGS.GUILD_MESSAGES,
        GatewayIntentBits.FLAGS.GUILD_MESSAGE_REACTIONS,
        GatewayIntentBits.FLAGS.GUILD_MESSAGE_TYPING,
        GatewayIntentBits.FLAGS.DIRECT_MESSAGES,
        GatewayIntentBits.FLAGS.DIRECT_MESSAGE_REACTIONS,
        GatewayIntentBits.FLAGS.DIRECT_MESSAGE_TYPING,
    ],
    partials: ["CHANNEL", "GUILD_MEMBER", "MESSAGE", "REACTION", "USER"],
    allowedMentions: {
        parse: ['users', 'roles'],
        repliedUser: false
    }
});

client.setMaxListeners(0)

module.exports = client;

the error i get on console GatewayIntentBits.FLAGS.GUILDS, ^

TypeError: Cannot read properties of undefined (reading 'GUILDS')

i had discord version 13 and i updated the client but i still get a error on flags.guilds.


Solution

  • As your error already states, FLAGS is not a property of GatewayIntentBits

    You can find the official documentation of braking changes here

    So according to the official docs, GatewayIntentBits.FLAGS.GUILDS should be GatewayIntentBits.Guilds