Skip to content

Host rooms

Chat and announcements

Speak to players, filter what they say and build chat commands.

Announcements

Announcements are host notices that stand apart from player chat. They work with or without a host player, can target one player and can be styled:

JavaScript
await room.sendAnnouncement(
  'Kickoff in 10 seconds',
  null,
  0xfacc15,
  'bold',
  2,
);

Choose colors that read well on a dark chat, and use sound 2 (alert) sparingly: each player's own sound settings still decide what they hear. See sendAnnouncement().

Chat as the host

With a host player (noPlayer: false), sendChat() posts as that player. Pass a player ID to send privately.

Filter room chat

onPlayerChat sees every room message before anyone else. Return false to stop it:

JavaScript
const banned = /\b(spam|scam)\b/i;
room.onPlayerChat = (player, text) => {
  if (banned.test(text)) return false;
};

The decision must be synchronous. An async handler returns a promise, and the message is delivered anyway.

Muted players and players who send more than a few messages a second are stopped before your handler runs.

Direct messages

Players can message each other directly. The host routes these messages, so onPlayerDirectChat can read them and stop delivery by returning false. Tell your players: direct messages are private from other players, not from the room.

Limits

MessageLimit
Player room and direct messages200 characters
Announcements1,000 characters

All text is literal. Markup is shown as typed and never interpreted.