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

162
Visualizações
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 Respostas
Responde à pergunta

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 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