Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
Invitar a registrar DiscordJS v13 TypeError: no se puede leer la propiedad 'invitador' de undefined

Código

 const id = "815280236974964817" client.on("ready", async () => { client.guilds.cache.get(id).invites.fetch().then(inv => { newInv = inv }) }) client.on("guildMemberAdd", async member =>{ if(member.guild.id !== id) return; member.guild.invites.fetch().then(gInvites =>{ const invite = gInvites.find((inv) => newInv.get(inv.code).uses < inv.uses) console.log(invite.inviter.tag) }) })

Error

 ^ TypeError: Cannot read property 'inviter' of undefined

Esto funcionó bien en discord.js v12. También tengo habilitados los intentos requeridos.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Este error te dice que la invite no está definida.

La función de find devuelve indefinido cuando no puede encontrar un elemento en la matriz que coincida con su función de prueba .

Necesita manejar este caso haciendo algo como esto:

 client.on("guildMemberAdd", async member =>{ if(member.guild.id !== id) return; member.guild.invites.fetch().then(gInvites =>{ const invite = gInvites.find((inv) => newInv.get(inv.code).uses < inv.uses) if (!invite) { // invite does not exist return; } else { // an invite matches the testing function console.log(invite.inviter.tag) } }) })
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!