From 7d02e73a260e8ed67d5cbd341a4da3f244d9e211 Mon Sep 17 00:00:00 2001 From: HyperCoder Date: Sun, 6 Nov 2016 11:43:39 -0500 Subject: [PATCH] Add .manageable (#878) --- src/structures/Role.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/structures/Role.js b/src/structures/Role.js index 685904219..891b8c92d 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -284,6 +284,18 @@ class Role { delete() { return this.client.rest.methods.deleteGuildRole(this); } + + /** + * Whether the role is managable by the client user. + * @type {boolean} + * @readonly + */ + get manageable() { + if (this.managed) return false; + const clientMember = this.guild.member(this.client.user); + if (!clientMember.hasPermission(Constants.PermissionFlags.MANAGE_ROLES_OR_PERMISSIONS)) return false; + return clientMember.highestRole.comparePositionTo(this) > 0; + } /** * Whether this role equals another role. It compares all properties, so for most operations