Check if user has a role

Hey guys! I'm wondering how you would check if a user has a specific role. Basically, I'm programming a game of tag and I'm using a role to track who is it(so it is clear whether you are it or not). I've seen people check permissions, but this role won't have any, and I have other roles which don't have perms as well. Can you please help?
12 Replies
d.js docs
d.js docs2y 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.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
samp
samp2y ago
it's not an error... that doesn't work for some reason, doesn't show up on autocomplete
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
samp
samp2y ago
i did a test role and it only sprouts false even though i have the role ... are you sure it's a thing??? *at least in v14.5.0
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
samp
samp2y ago
cuz it doesn't return true even though i have the role
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
samp
samp2y ago
what intents do i need? i have message content intents, but that's it... what intents do i need?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
samp
samp2y ago
huh ok i'll turn that on damn still doesn't work
if (interaction.commandName == 'tag') {
const itRole = interaction.member.guild.roles.cache.find(role => role.name === "announcement ping");
if (interaction.member.roles.cache.has(itRole)) {
interaction.reply({ content: "has role" });
}
else {
interaction.reply({ content: "no has role" });
}
}
if (interaction.commandName == 'tag') {
const itRole = interaction.member.guild.roles.cache.find(role => role.name === "announcement ping");
if (interaction.member.roles.cache.has(itRole)) {
interaction.reply({ content: "has role" });
}
else {
interaction.reply({ content: "no has role" });
}
}
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View