From d1e07674b865e7bb35f96177078614d83596fc71 Mon Sep 17 00:00:00 2001 From: Schuyler Cebulskie Date: Sat, 1 Oct 2016 02:54:25 -0400 Subject: [PATCH] Make GuildMember.kickable/bannable take role IDs into account --- src/structures/GuildMember.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/structures/GuildMember.js b/src/structures/GuildMember.js index f0b4dc572..b27ec4b6c 100644 --- a/src/structures/GuildMember.js +++ b/src/structures/GuildMember.js @@ -204,7 +204,10 @@ class GuildMember { if (this.user.id === this.client.user.id) return false; const clientMember = this.guild.member(this.client.user); if (!clientMember.hasPermission(Constants.PermissionFlags.KICK_MEMBERS)) return false; - return clientMember.highestRole.position > this.highestRole.position; + const clientRole = clientMember.highestRole; + const thisRole = this.highestRole; + return clientRole.position > thisRole.position || + (clientRole.position === thisRole.position && clientRole.id < thisRole.position); } /** @@ -217,7 +220,10 @@ class GuildMember { if (this.user.id === this.client.user.id) return false; const clientMember = this.guild.member(this.client.user); if (!clientMember.hasPermission(Constants.PermissionFlags.BAN_MEMBERS)) return false; - return clientMember.highestRole.position > this.highestRole.position; + const clientRole = clientMember.highestRole; + const thisRole = this.highestRole; + return clientRole.position > thisRole.position || + (clientRole.position === thisRole.position && clientRole.id < thisRole.position); } /**