#Role check
1 messages · Page 1 of 1 (latest)
Ok
If he has the role, it will return true
How can I have it do a specific reply if its false?
So operator is the interaction.member portion?
interaction.member.roles.cache.some huh?
So adding a not will convert the condition into checking if member doesn’t have the role
https://srcb.in/zPIb996FnM
Were talking about this @hoary atlas
The whole thing
Ohhhhhhhh ok
So I know lua pretty well, I can just throw an else at it
In javascript how can I do an "else"
else?
So it can read like
if user.has.role then
do whatever
else
do other thing
Yes that will work
So I can do else in javascript?
and else if
Else if isn’t anything new btw
if (!message.member.roles.cache.some(role => role.name === 'Something'))
else too isnt huh?
You just nest a if inside else
.
Thats confusing af
nah its nested
You can take it slow, I’m not the best at teaching lol
if (message.member.roles.cache.some(role => role.name === 'Something')) {
console.log("tthis guy have the role")
} else {
console.log("this guy don't have the role")
}
But you miss something
ig you are @tribal turtle
if()doing only one thing;
Yeah else is optional
You don't need {} if you put only one thing
Yeah that too a single statement doesn’t need a block
execute(interaction, member) {
if (
!interaction.member.roles.cache.some((role) => role.name === "Subscriber")
) {
interaction.reply({ content: "Download Sent", ephemeral: true });
interaction.member.send({
content: "Here is your download",
files: ["NW_minion_x64.exe"],
});
} else {
interaction.reply({
content: "You need to purchase before downloading",
ephemeral: true,
});
}
},
};```
So like this??
Lets try and see 😉
Should work perfectly
Remove the !
thats what it should do right?
Beautiful
Removing the ! worked
So ! means to strictly check
Or well
! if ur not using an else
Yup earlier you were using it to check if member doesn’t have the role, now you are using it to check if he has the role.
So the not is not needed
Ohhhhhhhhhhhhhh
execute(interaction, member) {
if (
interaction.member.roles.cache.some((role) => role.name === "NWB Subscriber" || interaction.member.roles.cache.some((role) => role.name === "NWB Premium Subscriber")
)) {
interaction.reply({ content: "Download Sent", ephemeral: true });
interaction.member.send({
content: "Here is your download",
files: ["NW_minion_x64.exe"],
});
} else {
interaction.reply({
content: "You need to purchase before downloading",
ephemeral: true,
});
}
},
};```
I learned how to do "or" and "and" aswell. Figured those would be massively useful like this 😉
I apprecaite the help @tribal turtle !!!!!
And the rest of yall

Btw there is one thing that will optimise your code.
.some iterates through the whole array, so since you are using it twice if go through the array twice. Better will be put that inside the callback:
role => role.name === 'name1' || role.name === 'name2'
Then a better to write the same thing is:
role => ['name1', 'name2'].includes(role.name)
😉
Wait what @tribal turtle Can u write that portion n show me what u mean?
interaction.member.roles.cache.some((role => ['NWB Subscriber', 'NWB Premium Subscriber'].includes(role.name))```
Like this?
Yes
That worked beautifully
