Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

defineTextChat

defineTextChat<Channels>(options?): TextChat<Channels>

Declares a game’s text chat: its channels and who receives a message. Export it from src/game.ts and re-export it from the room’s scene file beside the plugins, as export { plugins, room, textChat } from "../game". A game that exports none gets one all channel. The room decides every message: its sender, her right to send, the channel, the limits, the filter and each recipient; a game shapes who receives one, never what it says. defineRoom({ textChat: false }) turns chat off. As Roblox’s TextChatService, whose channels and delivery callback these are.

Type Parameter Default type
Channels extends Record<string, TextChannel> object
Parameter Type
options TextChatOptions<Channels>

TextChat<Channels>

export const textChat = defineTextChat({
channels: { all: textChannel(), team: teamTextChannel() },
// Ghosts receive everyone; the living never receive ghosts.
shouldDeliver: (world, sender, recipient) =>
!isGhost(world, sender) || isGhost(world, recipient),
});