Trying to get a list of members of a role

:peepoThink: I'm getting the message of a user (me) and then im trying this and the roleInfo is undefined
const roleId = 1239663214099169372;
const strRoleId = '1239663214099169372';
const roleInfo = message.guild.roles.cache.get(roleId);
const roleId = 1239663214099169372;
const strRoleId = '1239663214099169372';
const roleInfo = message.guild.roles.cache.get(roleId);
26 Replies
d.js toolkit
d.js toolkit7mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Squid
Squid7mo ago
Ids are strings, not numbers
sraech
sraechOP7mo ago
No description
Squid
Squid7mo ago
Roles should always be cached if you have the Guilds intent
JulianRJC
JulianRJC7mo ago
Does he have the Guild intent?
sraech
sraechOP7mo ago
:borpaPrayge: Indeed I do
No description
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
sraech
sraechOP7mo ago
:PauseFish: i have a full running bot, with alot going on, the stuff is running and also im getting a guild
No description
sraech
sraechOP7mo ago
:borpaPrayge: but the ID of the role is wrong
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
sraech
sraechOP7mo ago
No description
No description
sraech
sraechOP7mo ago
it's indeed unresolved, but still works
sraech
sraechOP7mo ago
thank you very much for the command on how to fetch roles :heh: I was really unable to find something in the docs, got dizzy looking for it
No description
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
sraech
sraechOP7mo ago
that would be then through the cache? guild.cache.roles.get
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
sraech
sraechOP7mo ago
14.14.1 :peepoThink: cannot read properties of undefined (reading 'roles'
duck
duck7mo ago
it'd be <Guild>.roles.cache.get()
sraech
sraechOP7mo ago
for understanding, why are the roles already cached :peepoThink:
duck
duck7mo ago
and to clarify, this is likely an issue with your ide webstorm and similar ides have historically had this issue with types
sraech
sraechOP7mo ago
webstorm indeed :heh:
duck
duck7mo ago
they're sent with the guild (in the guildCreate event) if you have the Guilds intent
sraech
sraechOP7mo ago
:SCagreed: very cool in that case, i can skip the await if i understood correctly
duck
duck7mo ago
correct, <Collection>.get() is synchronous
sraech
sraechOP7mo ago
:borpaPrayge: excellent, thank you very much duck have a duck :duckOhNo:
Want results from more Discord servers?
Add your server