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

67
Vistas
How do I cache all the members in the server when starting the bot using discordjs?

I currently need to ping the person first then it will cache into the bot. After that, I would then be able to use their ID.

How do I make it so I can use their ID straight away?

This is my avatar command. How would I go to improve and add that command?

module.exports = {
    config,
    run: async (client, message, args) => {
        let embed = new Discord.MessageEmbed();
        let mention = message.mentions.members.first()
        if(!mention && !isNaN(args[0]) && args[0]) try {mention = await client.users.fetch(args[0])} catch (err) {}
        if(!mention && args[0] && isNaN(args[0])) try {mention = await message.guild.members.fetch({query: args[0], limit: 1})} catch (err) {}
        if(!mention) mention = message.author
        if(mention.roles) mention = mention.user
        let user = message.mentions.users.first()
          || message.guild.members.cache.get(args[0])?.user
          || message.author;
            embed.setTitle('Avatar!');
            embed.setAuthor(message.author.tag, message.author.displayAvatarURL());
            embed.setColor(client.config.colors.info);
            embed.setImage(user.displayAvatarURL({dynamic: true}));
            return message.reply({embeds: [embed] });
        }
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You don't have to.

All members will be cached when your bot starts up (remember to put const client = new Client({ intents: [Intents.FLAGS.GUILDS] }); in your file!)

See the first code block here (under implementation).

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