fix: ensure VIEW_CHANNEL permissions before trying to join (#3046)

* fix: ensure VIEW_CHANNEL permissions before joining

* nit(GuildChannel): remove the redundant truthy check
This commit is contained in:
SpaceEEC
2019-02-10 16:21:59 +01:00
committed by Amish Shah
parent ff95e587cb
commit 7324a993ed
3 changed files with 17 additions and 4 deletions

View File

@@ -523,10 +523,21 @@ class GuildChannel extends Channel {
* @readonly
*/
get manageable() {
if (this.client.user.id === this.guild.ownerID) return true;
if (!this.viewable) return false;
return this.permissionsFor(this.client.user).has(Permissions.FLAGS.MANAGE_CHANNELS, false);
}
/**
* Whether the channel is viewable by the client user
* @type {boolean}
* @readonly
*/
get viewable() {
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], false);
return permissions.has(Permissions.FLAGS.VIEW_CHANNEL, false);
}
/**