Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

66
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda