backport: Permissions#toArray

This commit is contained in:
Lewdcario
2018-08-08 22:17:08 -05:00
parent 1e5b5b83c8
commit 6da423fc07

View File

@@ -155,6 +155,15 @@ class Permissions {
return this.missing(permissions, !explicit);
}
/**
* Gets an {@link Array} of permission names (such as `VIEW_CHANNEL`) based on the permissions available.
* @param {boolean} [checkAdmin=true] Whether to allow the administrator permission to override
* @returns {string[]}
*/
toArray(checkAdmin = true) {
return Object.keys(this.constructor.FLAGS).filter(perm => this.has(perm, checkAdmin));
}
/**
* Freezes these permissions, making them immutable.
* @returns {Permissions} These permissions