mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-10 12:42:44 +01:00
invite code gen
This commit is contained in:
parent
0b5176c702
commit
34e3d47f63
12
src/util/RandomInviteID.ts
Normal file
12
src/util/RandomInviteID.ts
Normal file
@ -0,0 +1,12 @@
|
||||
export function random(length = 6) {
|
||||
// Declare all characters
|
||||
let chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
||||
// Pick characers randomly
|
||||
let str = "";
|
||||
for (let i = 0; i < length; i++) {
|
||||
str += chars.charAt(Math.floor(Math.random() * chars.length));
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
Loading…
Reference in New Issue
Block a user