Class: Permissions
Extends
Constructors
Constructor
new Permissions(
bits?):Permissions
Parameters
| Parameter | Type |
|---|---|
bits? | BitFieldResolvable |
Returns
Permissions
Inherited from
Properties
bitfield
bitfield:
number|bigint
Inherited from
DefaultBit
staticDefaultBit:bigint=0n
Overrides
Flags
staticFlags:Record<string,number|bigint>
Overrides
Methods
[iterator]()
[iterator](...
hasParams):IterableIterator<string>
Iterates over the names of all flags that are set in this bitfield.
Parameters
| Parameter | Type |
|---|---|
...hasParams | any[] |
Returns
IterableIterator<string>
Example
for (const flag of perms) {
console.log(flag); // 'SendMessage', 'ViewChannel', etc.
}
Inherited from
add()
add(...
bits):this
Adds one or more bits to this bitfield. If the instance is frozen, returns a new BitField with the bits added.
Parameters
| Parameter | Type | Description |
|---|---|---|
...bits | PermissionResolvable[] | The bit(s) to add. |
Returns
this
This instance (or a new one if frozen), with the bits added.
Example
perms.add("SendMessage", "ViewChannel");
Overrides
any()
any(
bit):boolean
Checks whether this bitfield has any of the given bits set.
Parameters
| Parameter | Type | Description |
|---|---|---|
bit | PermissionResolvable | The bit(s) to test against. |
Returns
boolean
true if at least one of the provided bits is set.
Example
perms.any(["SendMessage", "ManageChannel"]); // true if either is set
Overrides
equals()
equals(
bit):boolean
Checks whether this bitfield is exactly equal to the given bit value.
Parameters
| Parameter | Type | Description |
|---|---|---|
bit | BitFieldResolvable | The bit(s) to compare against. |
Returns
boolean
true if the resolved bit value is identical to this bitfield.
Example
new Permissions(0n).equals(0n); // true
Inherited from
freeze()
freeze():
Readonly<this>
Freezes this BitField instance, making it immutable.
Subsequent calls to add() or remove() will return a new instance instead of mutating this one.
Returns
Readonly<this>
This instance, frozen.
Inherited from
has()
has(
bit):boolean
Checks whether this bitfield has all of the given bits set.
Parameters
| Parameter | Type | Description |
|---|---|---|
bit | PermissionResolvable | The bit(s) to check for. |
Returns
boolean
true if every provided bit is set in this bitfield.
Example
perms.has("SendMessage");
perms.has(["SendMessage", "ViewChannel"]); // true only if both are set
Overrides
missing()
missing(
bits): ("Video"|"ManageChannel"|"ManageServer"|"ManagePermissions"|"ManageRole"|"ManageCustomisation"|"KickMembers"|"BanMembers"|"TimeoutMembers"|"AssignRoles"|"ChangeNickname"|"ManageNicknames"|"ChangeAvatar"|"RemoveAvatars"|"ViewChannel"|"ReadMessageHistory"|"SendMessage"|"ManageMessages"|"ManageWebhooks"|"InviteOthers"|"SendEmbeds"|"UploadFiles"|"Masquerade"|"React"|"BypassSlowmode"|"Connect"|"Speak"|"MuteMembers"|"DeafenMembers"|"MoveMembers"|"Listen"|"MentionEveryone"|"MentionRoles"|"GrantAllSafe")[]
Returns the flag names present in bits that are missing from this bitfield.
Parameters
| Parameter | Type | Description |
|---|---|---|
bits | PermissionResolvable | The bits to check against. |
Returns
("Video" | "ManageChannel" | "ManageServer" | "ManagePermissions" | "ManageRole" | "ManageCustomisation" | "KickMembers" | "BanMembers" | "TimeoutMembers" | "AssignRoles" | "ChangeNickname" | "ManageNicknames" | "ChangeAvatar" | "RemoveAvatars" | "ViewChannel" | "ReadMessageHistory" | "SendMessage" | "ManageMessages" | "ManageWebhooks" | "InviteOthers" | "SendEmbeds" | "UploadFiles" | "Masquerade" | "React" | "BypassSlowmode" | "Connect" | "Speak" | "MuteMembers" | "DeafenMembers" | "MoveMembers" | "Listen" | "MentionEveryone" | "MentionRoles" | "GrantAllSafe")[]
An array of flag name strings that are in bits but not in this bitfield.
Example
// If perms only has SendMessage:
perms.missing(["SendMessage", "ManageChannel"]); // ['ManageChannel']
Overrides
remove()
remove(...
bits):this
Removes one or more bits from this bitfield. If the instance is frozen, returns a new BitField with the bits removed.
Parameters
| Parameter | Type | Description |
|---|---|---|
...bits | PermissionResolvable[] | The bit(s) to remove. |
Returns
this
This instance (or a new one if frozen), with the bits cleared.
Example
perms.remove("ManageChannel");
Overrides
serialize()
serialize(...
hasParams):Record<string,boolean>
Serializes this bitfield to a plain object mapping each flag name to a boolean indicating whether that flag is set.
Parameters
| Parameter | Type |
|---|---|
...hasParams | any[] |
Returns
Record<string, boolean>
A record of { [flagName]: boolean } for all defined flags.
Example
perms.serialize();
// { SendMessage: true, ManageChannel: false, ... }
Inherited from
toArray()
toArray(...
hasParams):string[]
Returns an array of flag names that are set in this bitfield.
Parameters
| Parameter | Type |
|---|---|
...hasParams | any[] |
Returns
string[]
An array of string flag names.
Example
perms.toArray(); // ['SendMessage', 'ViewChannel']
Inherited from
toJSON()
toJSON():
string|number
Returns the bitfield value as a JSON-safe primitive. Numbers are returned as-is; bigints are converted to their string representation to avoid JSON serialization errors.
Returns
string | number
Inherited from
valueOf()
valueOf():
number|bigint
Returns the underlying numeric value of this bitfield. Allows BitField instances to be used directly in arithmetic expressions.
Returns
number | bigint
Inherited from
resolve()
staticresolve(bit?):bigint
Resolves a BitFieldResolvable into a raw number | bigint.
Resolution rules (in order):
undefined→DefaultBit- A number or bigint matching
DefaultBit's type and >= 0 → returned as-is - A
BitFieldinstance → its.bitfieldvalue - An array → each element resolved and OR'd together
- A numeric string → parsed as
BigIntorNumberdepending onDefaultBit's type - A named string flag → looked up in
Flags - Anything else → throws
RangeError
Parameters
| Parameter | Type | Description |
|---|---|---|
bit? | PermissionResolvable | The value to resolve. |
Returns
bigint
Throws
If the value cannot be resolved to a valid bit.