diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-09-26 22:29:30 +1000 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-09-26 22:41:21 +1000 |
commit | 99ee7e9400f06e8718612d8b52d15215dc620774 (patch) | |
tree | 08de8c5d3985b9c2eaa419f5198f891ecd82d012 /src/api/util/utility/RandomInviteID.ts | |
parent | Remove the cdn storage location log (diff) | |
download | server-99ee7e9400f06e8718612d8b52d15215dc620774.tar.xz |
Prettier
Diffstat (limited to 'src/api/util/utility/RandomInviteID.ts')
-rw-r--r-- | src/api/util/utility/RandomInviteID.ts | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/api/util/utility/RandomInviteID.ts b/src/api/util/utility/RandomInviteID.ts index 7ea344e0..bfed65bb 100644 --- a/src/api/util/utility/RandomInviteID.ts +++ b/src/api/util/utility/RandomInviteID.ts @@ -2,7 +2,8 @@ import { Snowflake } from "@fosscord/util"; export function random(length = 6) { // Declare all characters - let chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + let chars = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; // Pick characers randomly let str = ""; @@ -15,18 +16,18 @@ export function random(length = 6) { export function snowflakeBasedInvite() { // Declare all characters - let chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + 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++) { - + for (let i = 0; i < 10; i++) { str.concat(chars.charAt(Number(snowflake % base))); snowflake = snowflake / base; } - - return str.substr(3,8).split("").reverse().join(""); + + return str.substr(3, 8).split("").reverse().join(""); } |