Random
Random generation and async utility functions.
No permission required.
Methods
id(length?)
Generate a short unique ID. Default length is 10.
| Parameter | Type | Default | Description |
|---|---|---|---|
length | number? | 10 | Character length of the ID |
typescript
const id = Random.id(); // e.g. "a3f8k2m9p1" (10 chars)
const short = Random.id(6); // e.g. "x7k2m9" (6 chars)uuid()
Generate a UUID (v4-like format).
typescript
const uuid = Random.uuid(); // e.g. "550e8400-e29b-41d4-a716-446655440000"number(min?, max?)
Generate a random integer.
typescript
const n = Random.number(1, 100); // 1-100 inclusivepassword()
Pick a random password from the game's built-in password list. Useful for generating realistic NPC credentials.
typescript
const pw = Random.password(); // e.g. "hunter2", "qwerty123", etc.username()
Pick a random username from the game's built-in username list. Useful for generating realistic NPC usernames.
typescript
const user = Random.username(); // e.g. "darknight", "cr4cker", etc.pick(array)
Pick a random element from an array. Throws an error if the array is empty or null.
typescript
const color = Random.pick(["red", "green", "blue"]);pickMultiple(array, count)
Pick multiple unique random elements. Throws an error if count exceeds the array length.
typescript
const team = Random.pickMultiple(["Alice", "Bob", "Charlie", "Dave"], 2);
// e.g. ["Charlie", "Alice"]sleep(ms)
Wait for a duration. Returns a Promise.
typescript
await Random.sleep(2000); // wait 2 seconds