Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

436
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda