Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

437
Vistas
discord.js guildCreate and guildDelete not firing

I am using discord.js to create a bot and have been following their guide until now to create the command and event handlers, including their format of putting each event handler and command function in its own file with its own exported module. This has worked fine for the 'ready' and 'interactionCreate' events, but for some reason my 'guildCreate' and 'guildDelete' events do not seem to be doing anything.

Here is how I am setting up the event listeners:

const eventsPath = path.join(__dirname, 'events');
const eventFiles = fs
    .readdirSync(eventsPath)
    .filter((file) => file.endsWith('.js'));

eventFiles.forEach((file) => {
    const filePath = path.join(eventsPath, file);
    const event = require(filePath);
    if (event.once) {
        client.once(event.name, (...args) => event.execute(...args));
    } else {
        client.on(event.name, (...args) => event.execute(...args));
    }
});

Here is the contents of guildCreate.js (guildDelete.js is the same except the name of the event is 'guildDelete'):

module.exports = {
    name: 'guildCreate',
    execute(guild) {
        console.log('joined guild');
        console.log(guild.name);
    },
};

I'm not sure why this is not printing anything as I can't see how it differs from the way the ready event is handled in the guide and that is working fine for me (https://discordjs.guide/creating-your-bot/event-handling.html#individual-event-files).

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Turns out that setting the intents to be 8 (the administrator permissions as calculated using the bit math calculator in the Discord Developer Portal) does not include access to guild events and I had to specifically set Intents.Flags.GUILDS

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda