So basically I have this nick command which changes the specified user nickname but if I will try to run that command on a person that has for example "Staff" Role and also me it'll say that it changed my name but I get an error on console. now I assume it's happening because the Staff Role is in a higher position from my bot and Idk what is the command or how to fix it.
client.on('message', async message => {
if(message.content.toLowerCase().startsWith(prefix + "nick")) {
if(message.content.toLowerCase() == prefix + "nick") return message.channel.send('Pls mention someone and do `.nick @user [your text]`')
const newEmbed = new Discord.MessageEmbed()
.setColor("RANDOM")
if(!message.member.hasPermission("MANAGE_NICKNAMES")) {
return message.channel.send("You do not have permission to do that since you're missing `manage_nicknames` perm")}
if(!message.guild.me.roles.highest.position) return message.channel.send("I can't change that user nickname since my role is lower than his one.")
if(message.author.bot) return;
if(message.guild === null) return
let args = message.content.slice(prefix.length).split(/ +/);
let mentionedUser = message.mentions.members.first() || message.guild.members.cache.get(args[1])
if(mentionedUser.hasPermission("ADMINISTRATOR")) return message.channel.send("I can't change this user nickname since he has `administrator` perm")
let name = args.slice(2).join(" ");
newEmbed.setDescription("**Mention a user to change his nickname.**")
.setTimestamp()
newEmbed.setDescription(`I have successfully changed **${mentionedUser.user.tag}** nickname to **${name}**.`);
mentionedUser.setNickname(name)
message.channel.send(newEmbed);
} else {
if(message.content.toLowerCase() === prefix + "help nick") {
const newEmbed = new Discord.MessageEmbed()
.setColor('#00B2B2')
.setTitle('**Nick Help**')
newEmbed.setDescription('this command is changing peoples names for example `.nick @user 123`.')
.setFooter(`Requested by ${message.author.tag}`, message.author.displayAvatarURL())
.setTimestamp();
message.channel.send(newEmbed)
}
}})