Triangle.js Docs
    Preparing search index...

    Class Room

    Index

    Properties

    allowAnonymous: boolean

    Whether or not the room allows anonymous users

    allowBots: boolean

    Whether or not the room allows bots

    allowChat: boolean

    Whether or not chatting is allowed

    allowQueued: boolean

    Whether or not the room allows users queued for TL

    allowUnranked: boolean

    Whether or not the room allows unranked users

    auto: Autostart

    The autostart state of the room

    autoStart: number

    The autostart config of the room

    bgmList: unknown[]

    The list of available BGMs

    chats: {
        content: string;
        content_safe?: string;
        pinned?: boolean;
        suppressable?: boolean;
        system: boolean;
        user: {
            _id: string | null;
            role?: Role;
            supporter?: boolean;
            supporter_tier?: number;
            username: string;
        };
    }[] = []

    Room chat history

    constants: unknown

    The room constants

    creator: string

    UID of the room creator (this person can reclaim host)

    forceRequireXPToChat: boolean

    Whether or not to force require XP to chat

    gamebgm: string

    The background music of the game

    gameStart: number | null = null

    The time the last game started

    id: string

    the ID of the room

    lobbybg: string | null

    The background image of the lobby

    lobbybgm: string

    The background music of the lobby

    match: Match

    The match config for the room

    name: string

    Name of the room

    name_safe: string

    Safe Name of the room

    options: Partial<Options>

    The room config. Note that TETR.IO does not send all options when joining a room, and some properties may not be present (hence the Partial)

    owner: string

    UID of the host

    players: Types.Room.Player[]

    The players in the room

    public: boolean

    Whether or not the room is public

    replay: ReplayManager | null = null

    The replay data for the last played game

    The current state of the room (ingame | lobby)

    type: Type

    The type of the room

    useBestRankAsLimit: boolean

    Whether or not to use best rank as limit

    userLimit: number

    The maxiumum number of players that can play in the room (override by moving as host)

    userRankLimit: Rank

    The user rank limit to play in the room

    Accessors

    • get isHost(): boolean

      Whether or not the client is the host

      Returns boolean

    Methods

    • Abort the game

      Returns Promise<null | undefined>

    • Ban a user from the room (if host) Uses room.kick under the hood, the same way TETR.IO does

      Parameters

      • id: string

        id of user to ban

      Returns Promise<string>

      await client.room!.ban('646f633d276f42a80ba44304');
      
    • Send a message to the room's chat. The pinned parameter is the same as using the /announce command in TETR.IO The pinned parameter being true will result in an error if the client is not host.

      Parameters

      • message: string
      • pinned: boolean = false

      Returns Promise<
          {
              content: string;
              content_safe?: string;
              pinned?: boolean;
              suppressable?: boolean;
              system: boolean;
              user: {
                  _id: string
                  | null;
                  role?: Role;
                  supporter?: boolean;
                  supporter_tier?: number;
                  username: string;
              };
          },
      >

      await client.room!.chat('hi!');
      
      await client.room!.chat('Important info:', true);
      
    • Clears the chat

      Returns Promise<void>

    • For internal use only. Use room.leave() instead.

      Returns void

    • Kick a user from the room for a specified duration (if host)

      Parameters

      • id: string

        id of user to kick

      • duration: number = 900

        duration to kick the user, in seconds

      Returns Promise<string>

      await client.room!.kick('646f633d276f42a80ba44304', 100);
      
    • Leave the current room

      Returns Promise<void>

      await client.room!.leave();
      
    • Move someone's bracket

      Parameters

      • uid: string
      • bracket: "player" | "spectator"

      Returns Promise<{ bracket: Bracket; uid: string } | undefined>

      await client.room!.move('646f633d276f42a80ba44304', 'spectator');
      
    • Sets the room id (only works for supporter accounts)

      Parameters

      • id: string

      Returns Promise<
          {
              allowAnonymous: boolean;
              allowBots: boolean;
              allowChat?: boolean;
              allowQueued: boolean;
              allowUnranked: boolean;
              auto: Autostart;
              autoStart: number;
              bgmList: unknown[];
              constants: unknown;
              creator: string;
              forceRequireXPToChat: boolean;
              gamebgm: string;
              id: string;
              info: Record<string, unknown>;
              lobbybg: string | null;
              lobbybgm: string;
              match: Match;
              name: string;
              name_safe?: string;
              options: Partial<Options>;
              owner: string;
              players: Types.Room.Player[];
              public: boolean;
              state: Types.Room.State;
              topic: Record<string, unknown>;
              type: Type;
              useBestRankAsLimit: boolean;
              userLimit: number;
              userRankLimit: Rank;
          },
      >

      client.room!.setID('TEST');
      
    • Start spectating a game.

      Returns Promise<void | SpectateData>

      The current state of the game being spectated.

      const data = await client.room!.spectate();
      
    • Start the game

      Returns Promise<Ready>

    • Switch bracket

      Parameters

      • bracket: "player" | "spectator"

      Returns Promise<{ bracket: Bracket; uid: string } | undefined>

      await client.room!.switch('player');
      
    • Take host if you created the room

      Returns Promise<string>

    • Give the host to someone else

      Parameters

      • player: string

      Returns Promise<string>

      await client.room!.transferHost(await client.social.resolve('halp'));
      
    • Unban a user from the room

      Parameters

      • username: string

      Returns Client

      client.room!.unban('halp');
      
    • Stop spectating the current game.

      Returns Promise<void>

      await client.room!.unspectate();
      
    • Update the room's config, similar to using the /set command in tetr.io await client.room!.update({ index: 'name', value: 'test room'});

      Parameters

      Returns Promise<
          {
              allowAnonymous: boolean;
              allowBots: boolean;
              allowChat?: boolean;
              allowQueued: boolean;
              allowUnranked: boolean;
              auto: Autostart;
              autoStart: number;
              bgmList: unknown[];
              constants: unknown;
              creator: string;
              forceRequireXPToChat: boolean;
              gamebgm: string;
              id: string;
              info: Record<string, unknown>;
              lobbybg: string | null;
              lobbybgm: string;
              match: Match;
              name: string;
              name_safe?: string;
              options: Partial<Options>;
              owner: string;
              players: Types.Room.Player[];
              public: boolean;
              state: Types.Room.State;
              topic: Record<string, unknown>;
              type: Type;
              useBestRankAsLimit: boolean;
              userLimit: number;
              userRankLimit: Rank;
          },
      >

    • Sets the room's preset

      Parameters

      Returns Promise<
          {
              allowAnonymous: boolean;
              allowBots: boolean;
              allowChat?: boolean;
              allowQueued: boolean;
              allowUnranked: boolean;
              auto: Autostart;
              autoStart: number;
              bgmList: unknown[];
              constants: unknown;
              creator: string;
              forceRequireXPToChat: boolean;
              gamebgm: string;
              id: string;
              info: Record<string, unknown>;
              lobbybg: string | null;
              lobbybgm: string;
              match: Match;
              name: string;
              name_safe?: string;
              options: Partial<Options>;
              owner: string;
              players: Types.Room.Player[];
              public: boolean;
              state: Types.Room.State;
              topic: Record<string, unknown>;
              type: Type;
              useBestRankAsLimit: boolean;
              userLimit: number;
              userRankLimit: Rank;
          },
      >

      await client.room!.usePreset('tetra league (season 1)');