Skip to main content

Message

The Message data type represents a single message sent to one or more players in the game. This includes both chat messages sent from player to player, and system messages sent from the server to players.

Data Type

The data type for Message is defined here, and is reproduced below for convenience:

export type Message = {
type: MessageType
author: {
playerNum: number
alias: string
}
message: string
visibility: number[] | 'all'
timestamp: number
}

The MessageType enum describes the type of message being sent, chosen from the following options:

export const enum MessageType {
/** A text chat message sent by a player */
Chat = 'chat',
/** An action taken by a player, such as voting */
Action = 'action',
/** An event that occurs in the game, such as a player dying */
Event = 'event',
}

Sample Data

Public Game Message

{
"author": {
"alias": "Game",
"playerNum": 0
},
"message": "The game has begun!",
"type": "event",
"visibility": "all",
"timestamp": 1630000000000
}

Private Game Message

{
"author": {
"alias": "Game",
"playerNum": 0
},
"message": "You will visit Jillana [1] tonight",
"type": "event",
"visibility": [
5
],
"timestamp": 1630000000000
}

Public Chat Message

{
"author": {
"alias": "Jillana",
"playerNum": 1
},
"message": "yo yo yo",
"type": "chat",
"visibility": "all",
"timestamp": 1630000000000
}

Public Action Message

{
"author": {
"alias": "Jillana",
"playerNum": 1
},
"message": "Jillana [1] has voted to accuse Myrilla [3]",
"type": "action",
"visibility": "all",
"timestamp": 1630000000000
}