Get a role

const role = interaction.client.roles.cache.get('ID')
const role = interaction.client.roles.cache.get('ID')
Is this correct if i want to get a role
12 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
PAdventures
PAdventures2y ago
k how would i use an if statement to check to see if the member has that role?
if (!interaction.member.roles.has(role))
if (!interaction.member.roles.has(role))
?
chewie 🌈
chewie 🌈2y ago
roles.cache.has
PAdventures
PAdventures2y ago
ok
const passRole = interaction.guild.roles.cache.get('ID')
if (!interaction.member.roles.cache.has(passRole)) {
return interaction.reply({ embeds: [roleDBEmbed], ephemeral:true })
}
const passRole = interaction.guild.roles.cache.get('ID')
if (!interaction.member.roles.cache.has(passRole)) {
return interaction.reply({ embeds: [roleDBEmbed], ephemeral:true })
}
with this the embed shows up yet i have the role
chewie 🌈
chewie 🌈2y ago
has takes an id, not a role object
PAdventures
PAdventures2y ago
ik, i just replaced the id with "ID" for the thing above only
chewie 🌈
chewie 🌈2y ago
thats not what I said
PAdventures
PAdventures2y ago
const passRole = interaction.guild.roles.cache.get('967861140656910436')
if (!interaction.member.roles.cache.has(passRole)) {
return interaction.reply({ embeds: [roleDBEmbed], ephemeral:true })
}
const passRole = interaction.guild.roles.cache.get('967861140656910436')
if (!interaction.member.roles.cache.has(passRole)) {
return interaction.reply({ embeds: [roleDBEmbed], ephemeral:true })
}
oh
chewie 🌈
chewie 🌈2y ago
has still takes an id, not a role object
PAdventures
PAdventures2y ago
how would i do that
chewie 🌈
chewie 🌈2y ago
pass an id idk whats not understandable here .has('id')
PAdventures
PAdventures2y ago
k thanks