From ef4bd92c8a56a50df3d6caea92b34d3c9ad90f0f Mon Sep 17 00:00:00 2001 From: Favna Date: Mon, 2 Apr 2018 20:00:47 +0200 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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/structures/GuildChannel.js b/src/structures/GuildChannel.js index b694ea822..b38a8cac1 100644 --- a/src/structures/GuildChannel.js +++ b/src/structures/GuildChannel.js @@ -539,6 +539,17 @@ class GuildChannel extends Channel { return 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); + return permissions && permissions.has([Permissions.FLAGS.MANAGE_CHANNELS, Permissions.FLAGS.VIEW_CHANNEL]); + } + /** * Deletes this channel. * @param {string} [reason] Reason for deleting this channel