Managing roles with name/id

Hi, my server have a role predefined called "officer", how could I dynamicaly get this role id ?
7 Replies
d.js toolkit
d.js toolkit17mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Post the full error stack trace, not just the top part! - Show your code! - Explain what exactly your issue is. - Not a discord.js issue? Check out #useful-servers. - Issue solved? Press the button!
MrMythical
MrMythical17mo ago
you can use guild.roles.cache.find(...)
Weac
WeacOP17mo ago
I must be missing something do you have a link to the doc of it ? To add more context : I am getting my role through the interaction of user, I would like to compare it to the roles "Off..."
console.log(interaction.member._roles);
console.log(interaction.member._roles);
But I find an id only from this console log, which is what I want, but I cannot get the id of my role to compare
MrMythical
MrMythical17mo ago
_roles is a private property, don't use it
Булочка | pasha_boez
Can you please explain why its not necessary to use private properties?
MrMythical
MrMythical17mo ago
See what Qjuh said
Булочка | pasha_boez
Yeah, I see that. But, if I need to get array of roles ids without everyone role, can I use private property? I just havent heard yet that its not worth using the private properties, and want to get explanation or source when I can read about that Okay, thanks!
Want results from more Discord servers?
Add your server