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

164
Views
DiscordJS GuildMemberRoleManager doesn't have a cache

I'm trying to see if a user has a role with discordjs v13. I'm using typescript as well.

On multiple posts, I've seen people use this code:

function handleCommand(interaction: CommandInteraction) {
...
  let isAdmin = interaction.member.roles.cache.some(role => role.name === 'Admin')
...

This is an example

However, I get an error:

  Property 'cache' does not exist on type 'string[]'.

22   console.log(interaction.member.roles.cache.some((r) => r.name == "Admin"));
                                          ~~~~~

What is the correct way to do this?

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

0

As Elitezen kindly pointed out, interaction.member.roles is a string[] instead of a GuildMemberRoleManager. I manually casted it to the correct type and it worked!

  let roles = (interaction.member.roles as GuildMemberRoleManager).cache;
  let isAdmin = roles.some(
    (role) => role.name === "admin")
  );
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!