SupMessage
The SupMessage object represents a message in a Sup conversation. It contains the message content, author information, and associated input/result data.
SupMessage: { "id": "zhgxm4knad2uzi32ylx1pqah", "body": "sup, world!", "author": { "id": "123", "username": "riffbit", "bio": "sup" }, "input": { "text": "sup, world!", "texts": ["sup, world!"], "image": undefined, "images": [], "audio": undefined, "audios": [], "video": undefined, "videos": [], "combined": ["sup, world!"] }}Properties
id
type: string
The unique identifier for the message.
body
type: string
The text content of the message.
author
type: SupUser
The user who sent this message.
input
type: SupInput
Input data that was specifically associated with this message.
result
type: SupInput | undefined
If this message is a reply to another message that ran a patch, contains the result data from that patch.
pinned
type: boolean
Whether this message is pinned in the chat.
metadata
type: any[] | undefined
// Access metadata from a replied-to messageconst gameState = sup.reply.metadata[0];const fen = gameState.fen;const pgn = gameState.pgn;An array of metadata objects attached to this message via sup.metadata(). Returns undefined if no metadata was attached. Each element in the array corresponds to a sup.metadata() call in the patch’s output.
reactions
type: { list(options?: { limit?: number }): SupReaction[]; add(emojiOrId: SupEmoji | string): void; remove(emojiOrId: SupEmoji | string): void }
// List reactions on the current messageconst reactions = sup.message.reactions.list({ limit: 20 });
// Add/remove by emoji idsup.message.reactions.add('emoji-id');sup.message.reactions.remove('emoji-id');
// Or with a SupEmoji objectconst thumbsUp = sup.emoji(':thumbsup:');if (thumbsUp) { sup.message.reactions.add(thumbsUp);}Message reaction helper methods:
list(options?): Returns all reactions on this message. Optionallimitcontrols how many reactions are returned.add(emojiOrId): Adds a reaction to this message.remove(emojiOrId): Removes a reaction from this message.
Each reaction returned by list() has:
Methods
set
type: function(key: string, value: any): void
sup.message.set("yes", ["riffbit"]);Sets a key-value pair in the patch’s state, scoped to the message containing the current patch run.
The key can be any string, and the value can be any JSON-serializable object (including Sup classes like SupUser, SupImage, SupMessage, etc.).
Message-scoped values are only accessible for the active message.
get
type: function(key: string): any | null
const yesVotes = sup.message.get("yes") || [];Retrieves the value of a key from the message’s state in this patch.
If the key does not exist, get returns null.
keys
type: function(): string[]
const keys = sup.message.keys(); // ["yes", "no", ...]Returns an array of all keys stored in this message’s scoped state.