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