39 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 OProles.delete is not how you remove a role
you're just mutating the cache
which you shouldnt
yes
oh
what do you suggest?
use the set method like you do now
but clone the collection instead of mutating
k one sec
like that?
also what would i use to add the
value
array to roles
?
.add isnt a functionclone is a function
and i'm not sure what that for loop is supposed to do
because <Collection>.add is not a function
nor would it be valid since that doesnt look like a snowflake
the values are what the users selected
tehy are in camel case
okay
and i turn em upper case to match the roleIDs in my json file
thats what i meant
.
yeah
what is the name of the function?
<Collection>.set
mapped by snowflake and role object
well i want to add certain roles
or just an array of snowflakes, probably easier
you need the id
not the name
so
you are using the name
where?
hold on
k
you're calling toUpperCase...on a Role?
ah no
still what i saod
im stupid
like that?
but if .add doesnt exist, how would i add the roles that the user selected to the roles they already have?
basically what im trying to do is when a user uses the select menu
any roles that they already have from the select menu (counterstrike, fortnite, etc.) are removed then it would add the roles they selected
this part
is entirely invalid
because you 1) have to use snowflakes, and 2 add is not a function
you either have to pass in a Collection keyed by snowflake and role, or an array of role id's
in your case the second would be the best
thats what im trying to do
just map the cache to an array, iterate over it and remove the roles you want
ROLE_IDS.value[i].toUpperCase();
the value of a selection is games_gameName
the name of the role id is GAMES_GAMENAME
so i get the ID and store it in the arrayno
you're storing the name of the role
regardless
that part of your code is just redundant
do this
ok
how would i map the cache to an array?
.map(r => r.id)
and then you would have to remove the ids you want to remove
which is just basic array stuff
yeah
whats r
a Role
so
roles.(game => game.id);
map on the cache
roles is the cache
cache.map
yes
ok thanks