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

172
Vistas
Check if user with a specific ID exists

I know you can get server member using let user = guild.members.cache.get('ID') and then check if member exists using if(!user) return, but how can I get a user with specific ID and check if this user exist at all if my bot doesn't share any servers with them?

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

0

This would be more suited as a comment to another answer but I can't yet add them so;

The second method in the answer I'm referencing is the best way, however is incorrect. client.users.fetch() does not return undefined. If no user exists, it errors, so instead you must do

let user;
try {
    user = await client.users.fetch("id", { force: true, cache: true }); // force skips cache checking so they don't need to be cached by the bot, cache will cache the user
} catch(err) {
    user = undefined;
}

// or
client.users.fetch("id", { force: true, cache: true })
.then(user => {
    // do something
})
.catch(err => {
    // user doesn't exist or another error occurred 
})
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