mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 18:43:31 +01:00
Document EvaluatedPermissions
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,11 +1,28 @@
|
|||||||
const Constants = require('../util/Constants');
|
const Constants = require('../util/Constants');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The final evaluated permissions for a member in a channel
|
||||||
|
*/
|
||||||
class EvaluatedPermissions {
|
class EvaluatedPermissions {
|
||||||
constructor(member, permissions) {
|
constructor(member, permissions) {
|
||||||
|
/**
|
||||||
|
* The member this permissions refer to
|
||||||
|
* @type {GuildMember}
|
||||||
|
*/
|
||||||
this.member = member;
|
this.member = member;
|
||||||
|
/**
|
||||||
|
* A number representing the packed permissions.
|
||||||
|
* @private
|
||||||
|
* @type {Number}
|
||||||
|
*/
|
||||||
this.permissions = permissions;
|
this.permissions = permissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an object mapping permission name, e.g. `READ_MESSAGES` to a boolean - whether the user
|
||||||
|
* can perform this or not.
|
||||||
|
* @returns {Object<String, Boolean>}
|
||||||
|
*/
|
||||||
serialize() {
|
serialize() {
|
||||||
const serializedPermissions = {};
|
const serializedPermissions = {};
|
||||||
for (const permissionName in Constants.PermissionFlags) {
|
for (const permissionName in Constants.PermissionFlags) {
|
||||||
@@ -15,7 +32,13 @@ class EvaluatedPermissions {
|
|||||||
return serializedPermissions;
|
return serializedPermissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasPermission(permission, explicit) {
|
/**
|
||||||
|
* Checks whether a user has a certain permission, e.g. `READ_MESSAGES`.
|
||||||
|
* @param {any} permission the permission to check for
|
||||||
|
* @param {any} [explicit=false] whether the user should explicitly have the permission.
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
hasPermission(permission, explicit = false) {
|
||||||
if (permission instanceof String || typeof permission === 'string') {
|
if (permission instanceof String || typeof permission === 'string') {
|
||||||
permission = Constants.PermissionFlags[permission];
|
permission = Constants.PermissionFlags[permission];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user