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

242
Vistas
TypeError: Cannot read property 'fetch' of undefined Discord.js for Invite Logger

This is the code which I am currently using for the Invite Logger and when I run it, it shows an error stating that it cannot read the 'fetch' property.

const invites = new Map();
const wait = require("timers/promises").setTimeout;

client.on("ready", async() => {
  await wait(1000);

  client.guilds.cache.forEach(async(guild) => {
    const firstInvites = await guild.invites.fetch();
    invites.set(guild.id, new Map(firstInvites.map((invite) => [invite.code, invite.uses])));
  });
});

client.on("inviteDelete", (invite) => {
  invites.get(invite.guild.id).delete(invite.code);
});

client.on("inviteCreate", (invite) => {
  invites.get(invite.guild.id).set(invite.code, invite.uses);
});

client.on("guildMemberAdd", member => {
  member.guild.invites.fetch().then(newInvites => {
    const oldInvites = invites.get(member.guild.id);
    const invite = newInvites.find(i => i.uses > oldInvites.get(i.code));
    const inviter = client.users.cache.get(invite.inviter.id);
    const logChannel = member.guild.channels.cache.find(channel => channel.name === "bot-testing");
    inviter
      ?
      logChannel.send(`${member.user.tag} joined using invite code ${invite.code} from ${inviter.tag}. Invite was used ${invite.uses} times since its creation.`) :
      logChannel.send(`${member.user.tag} joined but I couldn't find through which invite.`);
  });
});

This is the error message :

enter image description here

I am using Discord.js version 12.5.3 It would be great if someone can help me out :D

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

0

On v12.5.3, there is no GuildInviteManager.fetch() function, you'll have to use Guild.fetchInvites.

https://discord.js.org/#/docs/main/12.5.3/class/Guild?scrollTo=available

    const firstInvites = await guild.fetchInvites();
// ...
    member.guild.fetchInvites().then(newInvites => {
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