Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!