Discord JS Manage Roles Permission Missing even though bot is admin

Viewed 6756

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);
  }
}

enter image description here

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.

enter image description here DiscordAPIError: Missing Permissions

enter image description here

EDIT: For no reason, using only message.member.roles.add(proRole) makes my bot work :v

2 Answers

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

The bot's highest role must be higher than the role you need to assign in the role list, otherwise, it won't be able to give it to anyone.

Related