feat(GuildChannel): add manageable getter (#2439)

* Adds GuildChannel.manageable

* Resolve requested changes

* fix eslint max-len error

* Fix for nullable permissionsFor()

* Indent fixes
This commit is contained in:
Favna
2018-04-02 20:00:47 +02:00
committed by SpaceEEC
parent a5e8f05d01
commit ef4bd92c8a

View File

@@ -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