Takaro API Documentation

website·Indexed 32 days ago

https://docs.takaro.io

API reference for Takaro, featuring documentation for @takaro/helpers utility functions and @takaro/util Sentry logging and metrics modules.

Tokens
359.3K
Snippets
2.6K
Records
3.3K
Agent score
57%

What's inside Takaro

  1. Overview of Takaro Variables

    Variables in Takaro are key-value pairs stored in the database used to track data across different executions (e.g., tracking how many times a player has joined a server). Each variable can be linked to a specific GameServer, Player, and/or Module. Variable keys must be unique for each specific combination of GameServer, Player, and Module.
  2. Overview of @takaro/helpers module

    The @takaro/helpers module is a utility library used inside Takaro Functions. It provides essential tools for interacting with the Takaro environment, managing VM executions, and handling user-facing errors.
  3. Overview of Takaro Module Components

    Takaro is built around Modules, which are used to create features for Gameservers. A module can consist of three primary components:

    • Hooks: Callback functions triggered by specific events on a Gameserver (e.g., a player joining).
    • Cronjobs: Time-based triggers that can use simple patterns (e.g., "Every 5 minutes") or raw Cron syntax for complex schedules.
    • Commands: Manual actions triggered when a player sends a chat message starting with a configured prefix.
  4. Overview of Takaro Game Server Manager

    Takaro is a web-based, multi-gameserver manager that provides a web interface and a REST API for interacting with and managing multiple game servers.
  5. Overview of Takaro modules

    Takaro modules add features to a game server, allowing developers to implement consistent behavior across one or more servers without rewriting scripts. Modules can range from simple chat commands (e.g., /ping) to complex systems like economies, teleportation, onboarding, or Discord chat bridges.
  6. Overview of Takaro Multi-Gameserver Manager

    Takaro is a web-based, multi-gameserver manager that provides a web interface and a REST API for managing and interacting with gameservers.
  7. Overview of @takaro/queues module

    @takaro/queues is an opinionated queue manager for the Takaro ecosystem, built using BullMQ. It provides core classes for managing queues (TakaroQueue) and processing jobs (TakaroWorker), as well as utilities for Redis configuration and BullBoard integration.
  8. Use the EventPlayerDisconnected interface for player disconnect events

    The EventPlayerDisconnected interface in the @takaro/apiclient library represents an event triggered when a player disconnects from a game. It provides details about the player who left and the timing of the event.
    interface EventPlayerDisconnected {
      msg?: string; // Optional message associated with the disconnection
      player: IGamePlayer; // The game player object who disconnected
      timestamp: string; // The ISO timestamp of when the disconnection occurred
    }
  9. Use the ShopRecentOrderDTO interface for shop order data

    The ShopRecentOrderDTO interface in the @takaro/apiclient library represents a data transfer object for a recent shop order. It contains details about the item purchased, the player involved, the transaction value, and the order status.
    interface ShopRecentOrderDTO {
      id: string;
      itemName: string;
      playerId: string;
      playerName?: string;
      status: string;
      time: string;
      value: number;
    }
  10. Create a basic Takaro command

    Takaro modules use JavaScript/TypeScript. A basic command uses the @takaro/helpers library to access player data and send messages. The data object provides context about the player executing the command.
    import { takaro, data } from '@takaro/helpers';
    
    async function main() {
      const { player } = data;
      await player.pm('Hello, world!');
    }
    
    await main();