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

116
Views
How should I get a role object from id?

How should I get a role object from id? discord.js I'm using

message.guild.roles.cache(toString(role id here))
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

It's cache.get since cache is an instance of Collection

See <Collection>.get

message.guild.roles.cache.get(id)
about 4 years ago · Juan Pablo Isaza Report

0

In the latest versions of discord.js, <RoleManager>.cache has the type of Collection

So, to get a value stored in the collection, you'll be required to use the .get("key") method

Example:

const roleId = "your-role-id";
message.guild.roles.cache.get(roleId) // Returns <Role> object
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!