mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 18:13:29 +01:00
feat(Permissions): add any method (#3571)
* feat(Permissions): add any method * typings: add Permissions#any * fix(Permissions): resolve doesn't take a checkAdmin parameter Co-Authored-By: bdistin <bdistin@gmail.com> * docs(Permissions): remove trailing space, add returns annotation Co-authored-by: bdistin <bdistin@gmail.com>
This commit is contained in:
@@ -64,6 +64,17 @@ class Permissions {
|
||||
return (this.bitfield & permission) === permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the bitfield has a permission, or any of multiple permissions.
|
||||
* @param {PermissionResolvable} permissions Permission(s) to check for
|
||||
* @param {boolean} [checkAdmin=true] Whether to allow the administrator permission to override
|
||||
* @returns {boolean}
|
||||
*/
|
||||
any(permissions, checkAdmin = true) {
|
||||
return (checkAdmin && this.has(this.constructor.FLAGS.ADMINISTRATOR)) ||
|
||||
(this.bitfield & this.constructor.resolve(permissions)) !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all given permissions that are missing from the bitfield.
|
||||
* @param {PermissionResolvable} permissions Permissions to check for
|
||||
|
||||
Reference in New Issue
Block a user