From 49ad8cc2ccac996e634f80ccf5b67c1fbd521cb2 Mon Sep 17 00:00:00 2001 From: Isabella Date: Thu, 26 Apr 2018 01:31:52 -0500 Subject: [PATCH] feat(GuildChannel): add manageable getter (#2439) * Adds GuildChannel.manageable * Resolve requested changes * fix eslint max-len error * Fix for nullable permissionsFor() * Indent fixes --- src/structures/GuildChannel.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/structures/GuildChannel.js b/src/structures/GuildChannel.js index 735ce3bd9..6833a5b1c 100644 --- a/src/structures/GuildChannel.js +++ b/src/structures/GuildChannel.js @@ -380,6 +380,18 @@ class GuildChannel extends Channel { this.permissionsFor(this.client.user).has(Permissions.FLAGS.MANAGE_CHANNELS); } + /** + * Whether the channel is manageable by the client user + * @type {boolean} + * @readonly + */ + get manageable() { + if (this.client.user.id === this.guild.ownerID) return true; + const permissions = this.permissionsFor(this.client.user); + if (!permissions) return false; + return permissions.has([Permissions.FLAGS.MANAGE_CHANNELS, Permissions.FLAGS.VIEW_CHANNEL]); + } + /** * Whether the channel is muted * This is only available when using a user account.