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

166
Vistas
Discord.js Cannot get member by ID on ready function

I have not used the latest Discord.js version 13 so I am quite unfamiliar with it.

I am trying to get a member by its ID on the client ready function.

client.guilds.cache.get("x").members.cache.get("x")

Members returns as undefined. This however works with members.fetch(), but I am not able to use this in my code.

But for some reason, this code works

 client.guilds.cache.forEach((guild) => {
     guild.members.cache.forEach((member) => {
       console.log(member)
     });
   });

Please help as I have tried this in the previous Discord.js v12 and it works perfectly fine.

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

0

client.guilds.cache.get("x").members.cache.get("x") might not work due to either the guild or the member being uncached hence, unavialable to your client through cache you attemmpted to use member.fetch() as you said in your question although were unable to do so, maybe trying a wrong approach? let's try it right here!

client.once("ready", () => {
const guildId = 123456789012345678 // guild you want to fetch
const memberId = 123456789012345678 // member you want to fetch
client.guilds.fetch(`${guildId}`).then( (g) => { g.members.fetch(`${memberId}`) });
});

Easy stuff! feel free to comment if you face any other errors!

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