Role cache get undefined
When i using this it backs undefined how could i get the role
21 Replies
- 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!
- ✅
Marked as resolved by OPlog the id
or show your logs
and show the full error
no error,and console.log shows undefined
you have 2 logs there plus the one you were asked, which one logs undefined
The second which rolefetch log
and what does the first one log
Each admin_role snowflake
then there's no role with that id
make sure the ids in your config are correct and they're strings
yeah i sure its in the guild which have this role
wait let me check the guild fetch
929288640142663720
okay
but what exactly
do u mean config example?
...the ones logged in your console
936193745823621120(yellow color)
undefined(grey color)
log config.admin_role
wait
let me open laptop
[ 1314547409690300400, 936193745823621100, 1109490292438073500 ]
those are numbers, not strings. snowflakes are strings
snowflakes are larger than the max safe int in js, so they end up getting rounded if you convert them to a number. don't do that
you should also do one api request to modify the channel's permission overwrites for all desired roles/users at once, instead of multiple api requests (which might also have unintended results due to race conditions)
:Thinkeng: okay
but how to streamline the procedure
using this?

if it's for a channel you're creating, yes, you can pass all of the desired overwrites during the create request
but it will show such large array list
That's immaterial, it's just code
And one large array for one API request is better than several smaller arrays over multiple requests
If the permissions are the same for each role, then you can just define the array as a constant and reference that