Message Event
There are 8 unique types of messages, that all contain all the Event Data below, + message containing type + additional data specific to that message type.
Message Event Data
user is defined further below as User.
parts gives you a parsed version of text, as a Part array of text, emotes, and cheermotes.
first is true if this is a first-time chat message.
tags is the raw chat data from Twitch, if you need that.
remove is a function you can use to manually remove the rendered event if using managed mode.
type MessageEvent = {
type: 'message'
id: string // same as id in message
userId: string // same as id in user
renderable: true
remove: () => void
message: {
id: string
date: Date
user: User
text: string
parts: Part[]
first: boolean
tags: Map<string, string>
} & (
| BasicMessage
| ActionMessage
| HighlightMessage
| CheerMessage
| ReplyMessage
| RedeemMessage
| ResubMessage
| AnnouncementMessage
)
source: 'twitch'
}BasicMessage
Any message that isn't of a special type.
type BasicMessage = { type: 'basic' }ActionMessage
Messages created using the /me command.
type ActionMessage = { type: 'action' }HighlightMessage
Messages created using the "Highlight My Message" channel point reward.
type HighlightMessage = { type: 'highlight' }CheerMessage
Cheers (opens in a new tab) are messages that contains bits.
amount is the total number of bits cheered in the message.
type CheerMessage = {
type: 'cheer'
cheer: { amount: number }
}ReplyMessage
When a user uses the "Reply to Message" feature in chat.
reply contains details of the message being replied to.
type ReplyMessage = {
type: 'reply'
reply: {
id: string
text: string
user: {
id: string
userName: string
displayName: string
}
}
}RedeemMessage
When a user redeems a channel point reward that requires text.
redeem contains details of the channel point reward.
type RedeemMessage = {
type: 'redeem'
redeem: {
id: string
name: string
image: string
color: string
cost: number
}
}ResubMessage
When a user sends a resub message.
type ResubMessage = {
type: 'resub'
resub: {
months: number
tier: '1000' | '2000' | '3000' | 'Prime'
}
}AnnouncementMessage
When a moderator sends an announcement using /announce (opens in a new tab).
type AnnouncementMessage = {
type: 'announcement'
announcement: { color: 'PRIMARY' | 'BLUE' | 'GREEN' | 'ORANGE' | 'PURPLE' }
}User
pronouns is null if the user hasn't set pronouns.
color is set to a random twitch chat color if the user hasn't set a chat color. Their color will always be the same color for the entire session.
followDate is null if the user hasn't followed. The broadcaster is assigned new Date(0) (January 1, 1970, UTC).
type User = {
id: string
userName: string
displayName: string
badges: Badge[]
pronouns: string | null
color: string
followDate: Date | null
roles: {
broadcaster: boolean
moderator: boolean
artist: boolean
vip: boolean
founder: boolean
subscriber: boolean
}
}
type Badge = {
id: string
image: string
}Part
There are 3 kinds of parts, TextPart, CheerPart, and EmotePart. They all include the type and text properties.
Only channel emotes are parsed from BetterTTV (opens in a new tab) and FrankerFaceZ (opens in a new tab). Global emotes from those sources are not included.
type Part = { text: string } & (TextPart | CheerPart | EmotePart)
type TextPart = { type: 'text' }
type CheerPart = {
type: 'cheer'
name: string
amount: number
color: string
images: Images
}
type EmotePart = {
type: 'emote'
id: string
name: string
images: Images
source: 'twitch' | 'betterttv' | 'frankerfacez'
}
type Images = {
default: Urls
static: Urls
}
type Urls = {
x1: string
x2: string
x4: string
}7TV will never be supported, and widgets that include 7TV support will not be allowed on the forums. More information here: https://twitter.com/imZaytri/status/1461147801144868873 (opens in a new tab).