summary refs log tree commit diff
path: root/api
diff options
context:
space:
mode:
authorSamuel <34555296+Flam3rboy@users.noreply.github.com>2021-11-30 18:44:04 +0100
committerGitHub <noreply@github.com>2021-11-30 18:44:04 +0100
commit2245a82aa6969dd273c9406535ad32b7163f809b (patch)
treeac261f9136b7330e2d97b38bf3a218921ad5b9cf /api
parentMerge pull request #519 from erkinalp/master (diff)
parentFix the type errors (diff)
downloadserver-2245a82aa6969dd273c9406535ad32b7163f809b.tar.xz
Merge pull request #526 from erkinalp/patch-3
Diffstat (limited to 'api')
-rw-r--r--api/src/util/RandomInviteID.ts11
1 files changed, 6 insertions, 5 deletions
diff --git a/api/src/util/RandomInviteID.ts b/api/src/util/RandomInviteID.ts
index 45450b0d..30ba3252 100644
--- a/api/src/util/RandomInviteID.ts
+++ b/api/src/util/RandomInviteID.ts
@@ -16,16 +16,17 @@ export function random(length = 6) {
 export function snowflakeBasedInvite() {
 	// Declare all characters
 	let chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
-	
+	let base = BigInt(chars.length);
 	let snowflake = Snowflake.generateWorkerProcess();
-	
+
 	// snowflakes hold ~10.75 characters worth of entropy;
 	// safe to generate a 8-char invite out of them
 	let str = "";
 	for (let i=0; i < 10; i++) {
-		str += chars.charAt((snowflake % chars.length));
-		snowflake /= chars.length;
+		
+		str += chars.charAt(snowflake % base);
+		snowflake = snowflake / base;
 	}
 	
-	return str.substr(3,8).reverse(); // little-endianise for entropy
+	return str.substr(3,8).split("").reverse().join("");
 }