summary refs log tree commit diff
path: root/src/api/util
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-12-16 06:46:51 +0100
committerRory& <root@rory.gay>2025-12-16 06:46:51 +0100
commitcad820d33490862e0ee7ed248347dad3533b6039 (patch)
treedb31279e3b59e875d58186a492e9828215c1402b /src/api/util
parentIDE blew up again (diff)
downloadserver-ts-cad820d33490862e0ee7ed248347dad3533b6039.tar.xz
More maybe un-blowing-up
Diffstat (limited to 'src/api/util')
-rw-r--r--src/api/util/utility/RandomInviteID.ts17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/api/util/utility/RandomInviteID.ts b/src/api/util/utility/RandomInviteID.ts

index bd50ed92..3850df54 100644 --- a/src/api/util/utility/RandomInviteID.ts +++ b/src/api/util/utility/RandomInviteID.ts
@@ -24,8 +24,7 @@ import crypto from "crypto"; export function randomString(length = 6) { // Declare all characters - const chars = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; // Pick characers randomly let str = ""; @@ -38,8 +37,7 @@ export function randomString(length = 6) { export function snowflakeBasedInvite() { // Declare all characters - const chars = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; const base = BigInt(chars.length); let snowflake = Snowflake.generateWorkerProcess(); @@ -53,3 +51,14 @@ export function snowflakeBasedInvite() { return str.substr(3, 8).split("").reverse().join(""); } + +export function randomUpperString(length: number = 10) { + const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + let result = ""; + for (let i = 0; i < length; i++) { + result += chars.charAt(Math.floor(Math.random() * chars.length)); + } + + return result; +}