#Check if user a can manage user b?
14 messages · Page 1 of 1 (latest)
• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.
get manageable() {
if (this.user.id === this.guild.ownerId) return false;
if (this.user.id === this.client.user.id) return false;
if (this.client.user.id === this.guild.ownerId) return true;
if (!this.guild.members.me) throw new DiscordjsError(ErrorCodes.GuildUncachedMe);
return this.guild.members.me.roles.highest.comparePositionTo(this.roles.highest) > 0;
}
I've tried taking from this but it doesn't make sense to me
I saw a thread about this
making it a utility function
in developing djs
well basically, this.user.id will be the id of the user you want to check if you can manage
this.client is just regular client
this.guild is the guild the member is in
function canManage(interaction,target){
if (target.user.id === interaction.guild.ownerId) return false;
if (target.user.id === interaction.user.id) return false;
if (interaction.user.id === interaction.guild.ownerId) return true;
return interaction.member.roles.highest.comparePositionTo(target.roles.highest) > 0;
}
does this seem right?
Removed the discordjs error part
function canManage(interaction,target){
if (target.id === interaction.guild.ownerId) return false;
if (target.id === interaction.user.id) return false;
if (interaction.user.id === interaction.guild.ownerId) return true;
return interaction.member.roles.highest.comparePositionTo(interaction.guild.members.cache.get(target.id).roles.highest) > 0;
}
Kinda updated it