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

163
Views
discord.js Role Manager not showing role

I wanted to have a check on whether a user has a role or not, with a simple

let author = message.author.id
let guild = await client.guilds.fetch("guild")
let member = await guild.members.fetch(author)

member.roles.cache.has("role")

However, sometimes it returns false even though I just gave that member a role. And it still returns true after I remove their role. It'll work again only after I reset the bot.

Is this a bug or do I need to cache the member as a whole again? If so, how would I go about doing this to make it quick?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Seems like a cache issue you're facing...

I've not really developed using discord api however reading their documentation I get the impression that you should be using either:

await guild.members.fetch({ user: author/id, force: true });

The force flag specifies not to use cache in the query - more here. Obviously with disabling cache, you might experience performance degradation.

Additionally, the documentation specifies message.member object which might be doing this already for you, saving you a query or two.

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!