summary refs log tree commit diff
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-12-22 18:53:21 +1100
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-12-22 18:53:21 +1100
commitbf5f936aec6845a2cc6efb479c8b892fe8592de9 (patch)
treeeef18716a9073da05b0f08dc0bc0697874c4691d
parentMerge pull request #918 from Puyodead1/refactor/patch/disable-qr-login (diff)
downloadserver-bf5f936aec6845a2cc6efb479c8b892fe8592de9.tar.xz
Allow BitField's to be passed as number strings. Pretty sure it fixes #722
-rw-r--r--src/util/util/BitField.ts13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/util/util/BitField.ts b/src/util/util/BitField.ts
index 4e606660..e2f4e2a5 100644
--- a/src/util/util/BitField.ts
+++ b/src/util/util/BitField.ts
@@ -136,12 +136,22 @@ export class BitField {
 	static resolve(bit: BitFieldResolvable = BigInt(0)): bigint {
 		// @ts-ignore
 		const FLAGS = this.FLAGS || this.constructor?.FLAGS;
+
+		if (typeof bit === "string") {
+			if (typeof FLAGS[bit] !== "undefined")
+				return FLAGS[bit];
+			else
+				bit = BigInt(bit);
+		}
+
 		if (
 			(typeof bit === "number" || typeof bit === "bigint") &&
 			bit >= BigInt(0)
 		)
 			return BigInt(bit);
+
 		if (bit instanceof BitField) return bit.bitfield;
+
 		if (Array.isArray(bit)) {
 			// @ts-ignore
 			const resolve = this.constructor?.resolve || this.resolve;
@@ -149,8 +159,7 @@ export class BitField {
 				.map((p) => resolve.call(this, p))
 				.reduce((prev, p) => BigInt(prev) | BigInt(p), BigInt(0));
 		}
-		if (typeof bit === "string" && typeof FLAGS[bit] !== "undefined")
-			return FLAGS[bit];
+
 		throw new RangeError("BITFIELD_INVALID: " + bit);
 	}
 }