diff --git a/src/structures/EvaluatedPermissions.js b/src/structures/EvaluatedPermissions.js index 9deecba81..a4462692a 100644 --- a/src/structures/EvaluatedPermissions.js +++ b/src/structures/EvaluatedPermissions.js @@ -52,6 +52,16 @@ class EvaluatedPermissions { hasPermissions(permissions, explicit = false) { return permissions.map(p => this.hasPermission(p, explicit)).every(v => v); } + + /** + * Checks whether the user has all specified permissions, and lists any missing permissions. + * @param {PermissionResolvable[]} permissions The permissions to check for + * @param {boolean} [explicit=false] Whether to require the user to explicitly have the exact permissions + * @returns {array} + */ + missingPermissions(permissions, explicit = false) { + return permissions.filter(p => !this.hasPermission(p, explicit)); + } } module.exports = EvaluatedPermissions; diff --git a/src/structures/GuildMember.js b/src/structures/GuildMember.js index d23a9d240..305e1de94 100644 --- a/src/structures/GuildMember.js +++ b/src/structures/GuildMember.js @@ -253,6 +253,16 @@ class GuildMember { return permissions.map(p => this.hasPermission(p, explicit)).every(v => v); } + /** + * Checks whether the roles of the member allows them to perform specific actions, and lists any missing permissions. + * @param {PermissionResolvable[]} permissions The permissions to check for + * @param {boolean} [explicit=false] Whether to require the member to explicitly have the exact permissions + * @returns {array} + */ + missingPermissions(permissions, explicit = false) { + return permissions.filter(p => !this.hasPermission(p, explicit)); + } + /** * Edit a Guild Member * @param {GuildmemberEditData} data The data to edit the member with