My Discord bot isn't adding the role to the user who uses the command.
My Code:
if (userCmd.toLowerCase() === `${prefix}verify`) {
if (message.member.roles.cache.find(role => role.name === 'Rookie' && message.channel.id === '71xxxxxxxxxxx10')) {
const rookieRole = message.member.guild.roles.cache.find(role => role.name === 'Rookie')
const proRole = message.member.guild.roles.cache.find(role => role.name === 'Pro')
try {
if (message.guild.me.permissions.missing('MANAGE_ROLES')) return message.reply('I\'m missing permissions.');
if (message.author.id === message.guild.ownerID) return message.reply('I can\'t change your ROLE.');
message.member.roles.add(proRole)
} catch(err) {
console.error(err);
}
}
I tried everything possible: Removed and added the bot with all permissions again, moved the BOT ROLE at top in the hierarchy of roles, etc.
DiscordAPIError: Missing Permissions
EDIT:
For no reason, using only message.member.roles.add(proRole)
makes my bot work :v
I just came across this same problem, and nothing I did was helping out. Until, I came across a reddit post, 3 years old. That did the trick.
In server settings, literally drag the bots role above the roles it will be assigning.
Credit: Reddit Comment
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With