Check if user a can manage user b?

How is this possible from an interaction point?
4 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Isra
IsraOP3y ago
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;
}
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
MrMythical
MrMythical3y ago
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
Isra
IsraOP3y ago
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;
}
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;
}
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
Want results from more Discord servers?
Add your server