I'm making a bot that's gonna have a few moderator commands. I need to check if the bot has a higher role than the tagged user.
My code:
let mentionedRole = message.mentions.members.first().roles.highest
let botRole = client.user.roles.highest
if (mentionedRole.position > botRole.position) {
message.channel.send(`I dont have access to mute this member.${message.author}`)
return
}
The error shown:
let botRole = client.user.roles.highest
TypeError: Cannot read properties of undefined (reading 'highest')
So this (at least in my own opinion) would I think be easier, I would do this:
if (!message.mentions.members.first().manageable) {
// above if statement determines whether the client user is above this user in the hierarchy, according to role position and guild ownership.
message.channel.send(`I dont have access to mute this member.${message.author}`)
return
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments