Library

Actions and methods

Everything the host can do: room, match, moderation, teams and host.

All the methods below are fire-and-forget: they send the packet to the server and return. To know the result, listen to the matching events (see State and events).

Room

ts
room.setRoomName('New Name');
room.setRoomPassword('new_password');  // '' removes the password
room.chat('Hello!');

Match

ts
room.startGame();              // see "Matches, the IS blob and spectators" for the initial state
room.stopGame();               // sends everyone back to the lobby
room.startCountdown(3);        // 3 s countdown (default: 3)
room.abortCountdown();

room.setMode('b', 'b');        // engine, mode
room.setRounds(5);
room.setMap(lzStringBlob);     // changes the room map
room.setReady(true);           // marks the bot itself as ready
room.allReadyReset();          // resets everyone's "ready"

Moderation

ts
room.kickPlayer(id);   // kicks without banning
room.banPlayer(id);    // permanent ban

Teams and host

ts
// team: 0 spec · 1 ffa · 2 red · 3 blue · 4 green · 5 yellow
room.setTeam(id, 3);            // moves ANOTHER player (host only)
room.joinTeam(0);               // moves the bot ITSELF

room.lockTeams();               // locks: players can't switch teams on their own
room.unlockTeams();
room.setTeamsEnabled(true);     // turns team mode on/off

room.giveHost(id);              // hands over the host
room.setNoHostSwap(true);       // prevents automatic host swaps

More about locking teams in Teams and lock.

Anti-AFK

ts
room.enableAntiAfk({ thresholdMs: 12_000 });
room.isAfk(playerId);
room.disableAntiAfk();

See Anti-AFK.

Disconnect

ts
room.disconnect();   // idempotent: clears timers, internal listeners and state

Rate limits

The server limits how often several commands can be sent (team changes, lock, mode changes, countdown). When that happens you receive a status-message with a code such as rate_limit_tl. The library already avoids bursts where it can (for example, calling lockTeams() repeatedly sends the packet only once), but if you fire commands in a loop, space the calls out.