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:
Isabella
2018-04-26 01:31:52 -05:00
parent 7b9e84dff5
commit 49ad8cc2cc

View File

@@ -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
* <warn>This is only available when using a user account.</warn>