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

175
Visualizações
Print user is displaying user id in discord.js

I would like to list server members on Discord using discord.js library. However, some (mostly inactive) users are displayed in form <@123456789123456789> (their id) instead of @Michal (their clickable name with user profile).

It can be because some members are uncached? I tried fetch all members before printing them, even with force option. But without success.

const executeCommand = async (client, message) => {
    const members = await message.guild.members.fetch({ force: true })

    message.channel.send({ embed: {
        title: 'Members',
        description: members.map(m => `<@${m.id}>`).join(', ')
    } })
}

Also both Presence intent and Server member intent are enabled on my bot. How can I fix it?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

This is unfortunately not possible as the fact that the mentions show up as IDs and not the clickable usernames is actually an issue with the Discord client and not the bot itself but does indeed occur when the users haven't been fetched. If you restart your client, look at a message the person in question has sent, and then return to the message sent by the bot the username will show up and it's fully possible that what appears as just the ID for you shows up properly for someone else. If anything, this is something that has to be fixed by Discord themselves and out of our control as bot developers.

about 4 years ago · Juan Pablo Isaza Relatório

0

I don't know what causes it, but some mentions start with <@! instead of just <@.

I would recommend changing that map function to members.map(m => m.toString()), as you can see in docs, toString() method returns member's mention string.

https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=toString

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