Class: Chat
IRC client for Twitch chat - messages, cheers, subscriptions, and moderation events.
Constructor
import TwitchJs from 'twitch-js'
const { chat } = new TwitchJs({
username: 'your_username',
token: 'oauth:your_token'
})Methods
connect()
Connects to Twitch IRC.
await chat.connect()join()
Joins a channel.
await chat.join('#channelname')say()
Sends a message.
await chat.say('#channel', 'Hello!')Events
| Event | Description |
|---|---|
| PRIVMSG | Chat message |
| USERNOTICE | Sub, raid, ritual |
| CLEARCHAT | Ban/timeout |
Handling Cheers
chat.on('PRIVMSG', (msg) => {
if (msg.tags.bits) {
console.log(`${msg.username} cheered ${msg.tags.bits} bits!`)
}
})For bit values, see Twitch Bits Calculator.