Type alias TimerEvent

TimerEvent: {
    data?: JSONValue;
    id: string;
    interval?: number;
    name: string;
    postId: string;
}

Represents a scheduled timer event in the game.

Timer events can be one-time events or recurring intervals. They are persisted in Redis and survive server restarts.

Type declaration

  • Optional data?: JSONValue

    Optional data to associate with the timer event This is passed to the onTimerEvent handler

  • id: string

    Unique identifier for this specific timer instance

  • Optional interval?: number

    If present, makes the timer recurring with this interval (in milliseconds) If not present, the timer fires only once

  • name: string

    A name to identify the timer type Used for event handling logic

  • postId: string

    The Reddit post ID where this timer belongs

Example

// One-time event
const event: TimerEvent = {
postId: "t3_abc123",
name: "respawn_player",
id: "unique-uuid",
data: { playerId: "t2_xyz789" }
};

// Recurring event
const interval: TimerEvent = {
postId: "t3_abc123",
name: "spawn_asteroid",
id: "unique-uuid",
interval: 1000, // milliseconds
data: { maxAsteroids: 10 }
};