Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Discord JS Manage Roles Permission Missing even though bot is admin

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

like image 582
Dharmaraj Avatar asked Dec 23 '22 17:12

Dharmaraj


1 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

like image 78
biplobmanna Avatar answered Feb 22 '23 23:02

biplobmanna