diff --git a/src/util/Permissions.js b/src/util/Permissions.js index a0835870f..f1d8cac84 100644 --- a/src/util/Permissions.js +++ b/src/util/Permissions.js @@ -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 diff --git a/typings/index.d.ts b/typings/index.d.ts index 91eee94da..808d6c98c 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -984,6 +984,7 @@ declare module 'discord.js' { public bitfield: number; public member: GuildMember; public add(...permissions: PermissionResolvable[]): this; + public any(permissions: PermissionResolvable, checkAdmin?: boolean): boolean; public freeze(): this; public has(permission: PermissionResolvable, checkAdmin?: boolean): boolean; public hasPermission(permission: PermissionResolvable, explicit?: boolean): boolean;