From 16b9ee3bc55d2e1d5ea40f9c0452d0aff9bfe5df Mon Sep 17 00:00:00 2001 From: Yuzu Date: Wed, 7 Sep 2022 22:14:52 -0500 Subject: [PATCH] fix: confusing behavior on permissions --- packages/core/src/structures/special/permissions.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/core/src/structures/special/permissions.ts b/packages/core/src/structures/special/permissions.ts index 5e02684..16dfaad 100644 --- a/packages/core/src/structures/special/permissions.ts +++ b/packages/core/src/structures/special/permissions.ts @@ -25,13 +25,21 @@ export class Permissions implements BitField { /** Stores all entity permissions */ bitfield: bigint; - /** Wheter to grant all other permissions to the administrator */ + /** + * Wheter to grant all other permissions to the administrator + * **Not to get confused with Permissions#admin** + */ __admin__ = true; constructor(bitfield: PermissionResolvable) { this.bitfield = Permissions.resolve(bitfield); } + /** Wheter the bitfield has the administrator flag */ + get admin(): boolean { + return (this.bitfield & BigInt(Permissions.Flags.ADMINISTRATOR)) === this.bitfield; + } + get array(): PermissionString[] { // unsafe cast, do not edit const permissions = Object.keys(Permissions.Flags) as PermissionString[];