Blausein Blau
Blausein Blau

Reputation: 13

Discord.js bot dosnt have permission to manage Nicknames

I gave my discord bot the admin permission, and put the role above every other role, but it seems like the bot dosnt have the permission to change NickNames even if i check for it.

if (msg.content === '!ping') {
    msg.reply('Pong!')
    msg.reply(msg.author.username)
    msg.member.setNickname('RandomName').catch(e=>console.log(e))
    console.log(msg.guild.members.find("id",client.user.id).hasPermission("MANAGE_NICKNAMES"));
}

It gives me the answer true to the check if I have the permission, but it gives me the error: DiscordAPIError: Missing Permissions to the setNickname Command.

Upvotes: 0

Views: 4090

Answers (1)

slothiful
slothiful

Reputation: 5623

The bot can't change the nickname of a guild owner or a member with a higher role. Check to make sure that the user isn't the owner first.

try {
  if (msg.guild.me.permissions.missing('MANAGE_NICKNAMES')) return msg.reply('I\'m missing permissions.');
  if (msg.author.id === msg.guild.ownerID) return msg.reply('I can\'t change your nickname.');

  msg.member.setNickname('test');
} catch(err) {
  console.error(err);
}

Upvotes: 2

Related Questions