mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
refactor(BitField): base class for Permissions, ActivityFlags, Speaking (#2765)
* abstract BitField from Permissions * reduce useless code, improve docs * add a ReadOnly identifier to the return type of Bitfield#freeze() https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-1.html#partial-readonly-record-and-pick * fix the RangeError * update docs, convert Speaking and ActivityFlags to bitfields * fix some docs * Fix Speaking BitField oops * docs for oops * more incorrect docs * Fix incorrectly named property * add new classes to index * fix missing @extends docs * default bitfield resolve to 0, and cleanup defaulting everywhere Also removes GuildMember#missiongPermissions() alias that had incorrect behavior * Breaking: Rename Overwrite allowed and denied to allow and deny To be consistent with the api's naming * fix setSpeaking usage to bitfields instead of booleans * fix speaking bug in playChunk * docs: Updated typings * fix: BitFieldResolvable should use RecursiveArray * bugfix/requested change * typings: Cleanup (#2) * typings: Fix BitField#{toArray,@@iterator} output type * typings: correct PermissionOverwrites property names and nitpicks
This commit is contained in:
@@ -168,7 +168,7 @@ class GuildMember extends Base {
|
||||
|
||||
/**
|
||||
* The overall set of permissions for this member, taking only roles into account
|
||||
* @type {Permissions}
|
||||
* @type {ReadOnly<Permissions>}
|
||||
* @readonly
|
||||
*/
|
||||
get permissions() {
|
||||
@@ -209,7 +209,7 @@ class GuildMember extends Base {
|
||||
* Returns `channel.permissionsFor(guildMember)`. Returns permissions for a member in a guild channel,
|
||||
* taking into account roles and permission overwrites.
|
||||
* @param {ChannelResolvable} channel The guild channel to use as context
|
||||
* @returns {?Permissions}
|
||||
* @returns {ReadOnly<Permissions>}
|
||||
*/
|
||||
permissionsIn(channel) {
|
||||
channel = this.guild.channels.resolve(channel);
|
||||
@@ -230,16 +230,6 @@ class GuildMember extends Base {
|
||||
return this.roles.some(r => r.permissions.has(permission, checkAdmin));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the roles of this 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 {PermissionResolvable[]}
|
||||
*/
|
||||
missingPermissions(permissions, explicit = false) {
|
||||
return this.permissions.missing(permissions, explicit);
|
||||
}
|
||||
|
||||
/**
|
||||
* The data for editing a guild member.
|
||||
* @typedef {Object} GuildMemberEditData
|
||||
|
||||
Reference in New Issue
Block a user