diff --git a/src/structures/GuildChannel.js b/src/structures/GuildChannel.js index fba55eaa8..fb32b141d 100644 --- a/src/structures/GuildChannel.js +++ b/src/structures/GuildChannel.js @@ -73,6 +73,22 @@ class GuildChannel extends Channel { return this.guild.channels.get(this.parentID) || null; } + /** + * If the permissionOverwrites match the parent channel, null if no parent + * @type {?boolean} + * @readonly + */ + get permissionsLocked() { + if (!this.parent) return null; + if (this.permissionOverwrites.size !== this.parent.permissionOverwrites.size) return false; + return this.permissionOverwrites.every((value, key) => { + const testVal = this.parent.permissionOverwrites.get(key); + return testVal !== undefined && + testVal.deny === value.deny && + testVal.allow === value.allow; + }); + } + /** * Gets the overall set of permissions for a user in this channel, taking into account channel overwrites. * @param {GuildMemberResolvable} member The user that you want to obtain the overall permissions for diff --git a/typings/index.d.ts b/typings/index.d.ts index 96ef73bc7..37816cc17 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -632,6 +632,7 @@ declare module 'discord.js' { public parentID: Snowflake | null; public permissionOverwrites: Collection; public position: number; + public readonly permissionsLocked: boolean | null; public clone(name?: string, withPermissions?: boolean, withTopic?: boolean, reason?: string): Promise; public createInvite(options?: InviteOptions, reason?: string): Promise; public delete(reason?: string): Promise;