diff --git a/src/structures/GuildChannel.js b/src/structures/GuildChannel.js index dc0a4e415..9904e4c14 100644 --- a/src/structures/GuildChannel.js +++ b/src/structures/GuildChannel.js @@ -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); } /** diff --git a/src/structures/VoiceChannel.js b/src/structures/VoiceChannel.js index cf9b1ee99..2d1fa956e 100644 --- a/src/structures/VoiceChannel.js +++ b/src/structures/VoiceChannel.js @@ -71,14 +71,15 @@ class VoiceChannel extends GuildChannel { } /** - * Checks if the client has permission join the voice channel + * Whether the channel is joinable by the client user * @type {boolean} * @readonly */ get joinable() { if (browser) return false; - if (!this.permissionsFor(this.client.user).has('CONNECT', false)) return false; - if (this.full && !this.permissionsFor(this.client.user).has('MOVE_MEMBERS', false)) return false; + if (!this.viewable) return false; + if (!this.permissionsFor(this.client.user).has(Permissions.FLAGS.CONNECT, false)) return false; + if (this.full && !this.permissionsFor(this.client.user).has(Permissions.FLAGS.MOVE_MEMBERS, false)) return false; return true; } diff --git a/typings/index.d.ts b/typings/index.d.ts index 60a19f3db..dccd33049 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -523,6 +523,7 @@ declare module 'discord.js' { public readonly permissionsLocked: boolean; public readonly position: number; public rawPosition: number; + public readonly viewable: boolean; public clone(options?: GuildChannelCloneOptions): Promise; public createInvite(options?: InviteOptions): Promise; public createOverwrite(userOrRole: RoleResolvable | UserResolvable, options: PermissionOverwriteOption, reason?: string): Promise;