Skip to content

Commit

Permalink
fix(Permissions): toArray shouldn't check admin (#7144)
Browse files Browse the repository at this point in the history
  • Loading branch information
DTrombett committed Dec 26, 2021
1 parent 7e5f16b commit fc4292e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/util/Permissions.js
Expand Up @@ -31,7 +31,7 @@ class Permissions extends BitField {
* @returns {string[]}
*/
missing(bits, checkAdmin = true) {
return checkAdmin && this.has(this.constructor.FLAGS.ADMINISTRATOR) ? [] : super.missing(bits, checkAdmin);
return checkAdmin && this.has(this.constructor.FLAGS.ADMINISTRATOR) ? [] : super.missing(bits);
}

/**
Expand All @@ -53,6 +53,14 @@ class Permissions extends BitField {
has(permission, checkAdmin = true) {
return (checkAdmin && super.has(this.constructor.FLAGS.ADMINISTRATOR)) || super.has(permission);
}

/**
* Gets an {@link Array} of bitfield names based on the permissions available.
* @returns {string[]}
*/
toArray() {
return super.toArray(false);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion typings/index.d.ts
Expand Up @@ -1851,7 +1851,7 @@ export class Permissions extends BitField<PermissionString, bigint> {
public has(permission: PermissionResolvable, checkAdmin?: boolean): boolean;
public missing(bits: BitFieldResolvable<PermissionString, bigint>, checkAdmin?: boolean): PermissionString[];
public serialize(checkAdmin?: boolean): Record<PermissionString, boolean>;
public toArray(checkAdmin?: boolean): PermissionString[];
public toArray(): PermissionString[];

public static ALL: bigint;
public static DEFAULT: bigint;
Expand Down

0 comments on commit fc4292e

Please sign in to comment.