feat(GuildChannel): backport permissionsLocked getter (#3507)

* backport(GuildChannel): GuildChannel#permissionsLocked

* typings: GuildChannel#permissionsLocked

* fix(typings): mark permissionsLocked getter as readonly
This commit is contained in:
Souji
2019-10-04 16:43:12 +02:00
committed by SpaceEEC
parent 8ddd0616a9
commit 2610bf57ae
2 changed files with 17 additions and 0 deletions

View File

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

1
typings/index.d.ts vendored
View File

@@ -632,6 +632,7 @@ declare module 'discord.js' {
public parentID: Snowflake | null;
public permissionOverwrites: Collection<Snowflake, PermissionOverwrites>;
public position: number;
public readonly permissionsLocked: boolean | null;
public clone(name?: string, withPermissions?: boolean, withTopic?: boolean, reason?: string): Promise<GuildChannel>;
public createInvite(options?: InviteOptions, reason?: string): Promise<Invite>;
public delete(reason?: string): Promise<GuildChannel>;