Skip to content

Commit

Permalink
feat(Permissions): Add bigint support for perm check (#1374)
Browse files Browse the repository at this point in the history
Co-authored-by: Donovan Daniels <[email protected]>
  • Loading branch information
bsian03 and DonovanDMC authored May 27, 2022
1 parent 2f7526a commit e963166
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3148,7 +3148,7 @@ declare namespace Eris {
deny: bigint;
json: Record<keyof Constants["Permissions"], boolean>;
constructor(allow: number | string | bigint, deny?: number | string | bigint);
has(permission: keyof Constants["Permissions"]): boolean;
has(permission: keyof Constants["Permissions"] | bigint): boolean;
}

export class PermissionOverwrite extends Permission {
Expand Down
5 changes: 4 additions & 1 deletion lib/structures/Permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ class Permission extends Base {

/**
* Check if this permission allows a specific permission
* @arg {String} permission The name of the permission. [A full list of permission nodes can be found on the docs reference page](/Eris/docs/reference)
* @arg {String | BigInt} permission The name of the permission, or bit of permissions. [A full list of permission nodes can be found on the docs reference page](/Eris/docs/reference). Pass a BigInt if you want to check multiple permissions.
* @returns {Boolean} Whether the permission allows the specified permission
*/
has(permission) {
if(typeof permission === "bigint") {
return (this.allow & permission) === permission;
}
return !!(this.allow & Permissions[permission]);
}

Expand Down

0 comments on commit e963166

Please sign in to comment.