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 User3y ago
Message Not Public
Sign In & Join Server To View
PAdventures
PAdventuresOP3y 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
chewie3y ago
roles.cache.has
PAdventures
PAdventuresOP3y 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
chewie3y ago
has takes an id, not a role object
PAdventures
PAdventuresOP3y ago
ik, i just replaced the id with "ID" for the thing above only
chewie
chewie3y ago
thats not what I said
PAdventures
PAdventuresOP3y 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
chewie3y ago
has still takes an id, not a role object
PAdventures
PAdventuresOP3y ago
how would i do that
chewie
chewie3y ago
pass an id idk whats not understandable here .has('id')
PAdventures
PAdventuresOP3y ago
k thanks
Want results from more Discord servers?
Add your server