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

268
Visualizações
DiscordJS cannot get _roles field after fetching member

I am fetching a member as:

//...
private user: GuildMember;
//...

try { 
    this.user = await interaction.guild?.members.fetch(SomeUserId)
}catch (e: unknown) {
    return await interaction.editReply("Couldn't find the specific user the in server.")
}

this.user will contain all the information regarding that specific user. It also includes a field _roles:['123456789', '123456789']. How can I get this specific field? Note that doing the following results in '_roles does not exist on type GuildMember':

console.log(this.user._roles)

Any way to access this field?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Found it!

...
private user: GuildMember | undefined; // Make sure to add undefined here too. Since .fetch returns a GuildMember or undefined
...

//To get that array use:
Array.from(this.user.roles.cache.keys())

//To get the Collection:
this.user.roles.cache.keys()

Leaving this here for that one random person that also has the same issue after 8 years.

about 4 years ago · Santiago Trujillo 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