'Cannot read properties of undefined (reading 'comparePositionTo'
I'm making a kick slashCommand in discord.js v13 and i was trying to compared the user roles and the target role but it doesn't work, I don't know why is that
here's my code:
If(interaction.member.highest.comparePositionTo(target.roles.highest.position > 0)) {
const kickErr = new MessageEmbed()
.setDescription(`You cannt kick this member because their role is higher/equal to yours.`)
.setColor(ee.color)
return interaction.reply({ embeds: [kickErr] })
} else if (interaction.guild.me.roles.highest.comparePositionTo(target.roles.highest.position > 0)) {
const kickErr2 = new MessageEmbed()
.setDescription(`I cannot kick this member because their role is higher/equal to mine.`)
.setColor(ee.color)
return interaction.reply({ embeds: [kickErr2] })
}
Solution 1:[1]
It looks like you have this error because on the first line of your code you used
if(interaction.member.highest.comparePositionTo(targ...
Instead of
if(interaction.member.roles.highest.comparePositionTo(targ...
Also, next time you post a question on stackoverflow, make sure to add the full error stack in your post to make it easier to understand
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | SkwalExe |
