Some events will only be fired if you are logged in. If you are not familiar with event listeners, please read this.
Received action message on channel. (/me <message>)
Parameters:
channel: String - Channel nameuser: Object - User objectmessage: String - Message receivedself: Boolean - Message was sent by the clientclient.on("action", function (channel, user, message, self) {
// Do your stuff.
});
According to Twitch, the user object is always subject to change.
{
color: '#FFFFFF',
'display-name': 'Schmoopiie',
emotes: { '25': [ '0-4' ] },
subscriber: false,
turbo: true,
'user-type': 'mod',
'emotes-raw': '25:0-4',
username: 'schmoopiie'
}
Received message on channel.
Parameters:
channel: String - Channel nameuser: Object - User objectmessage: String - Message receivedself: Boolean - Message was sent by the clientclient.on("chat", function (channel, user, message, self) {
// Do your stuff.
});
According to Twitch, the user object is always subject to change.
{
color: '#FFFFFF',
'display-name': 'Schmoopiie',
emotes: { '25': [ '0-4' ] },
subscriber: false,
turbo: true,
'user-type': 'mod',
'emotes-raw': '25:0-4',
username: 'schmoopiie'
}
Chat of a channel got cleared.
Parameters:
channel: String - Channel nameclient.on("clearchat", function (channel) {
// Do your stuff.
});
Connected to server.
Parameters:
address: String - Remote addressport: Integer - Remote portclient.on("connected", function (address, port) {
// Do your stuff.
});
Connecting to a server.
Parameters:
address: String - Remote addressport: Integer - Remote portclient.on("connecting", function (address, port) {
// Do your stuff.
});
Got disconnected from server.
Parameters:
reason: String - Reason why you got disconnectedclient.on("disconnected", function (reason) {
// Do your stuff.
});
Received the emote-sets from Twitch. The emote-sets contains your emote set, which you can use to request a subset of https://api.twitch.tv/kraken/chat/emoticon_images
Example: https://api.twitch.tv/kraken/chat/emoticon_images?emotesets=0,27,33,793
Parameters:
sets: String - Your emote sets (always contains at least 0)client.on("emotesets", function(sets) {
// Using our API function..
client.api({
url: "/chat/emoticon_images?emotesets=" + sets
}, function(err, res, body) {
console.log(body);
});
});
Channel is now hosted by another broadcaster. This event is fired only if you are logged in as the broadcaster.
Parameters:
channel: String - Channel name being hostedusername: String - Username hosting youviewers: Integer - Viewers countclient.on("hosted", function (channel, username, viewers) {
// Do your stuff.
});
Channel is now hosting another channel.
Parameters:
channel: String - Channel name that is now hostingtarget: String - Channel being hostedviewers: Integer - Viewers countclient.on("hosting", function (channel, target, viewers) {
// Do your stuff.
});
Username has joined a channel. Not available on large channels and is also sent in batch every 30-60secs.
Parameters:
channel: String - Channel nameusername: String - Usernameclient.on("join", function (channel, username) {
// Do your stuff.
});
Connection established, sending informations to server.
client.on("logon", function () {
// Do your stuff.
});
Someone got modded on a channel.
Important: It doesn't detect if username is a new moderator, it is triggered when jtv gives the moderator status to someone on a channel. You will see a lot of mod / unmod events on a channel. When a moderator joins a channel, it will take a few seconds for jtv to give the user the moderator status. When leaving a channel, the user gets unmodded.
Parameters:
channel: String - Channel nameusername: String - Usernameclient.on("mod", function (channel, username) {
// Do your stuff.
});
Received the list of moderators of a channel.
Parameters:
channel: String - Channel namemods: Array - Moderators of the channelclient.on("mods", function (channel, mods) {
// Do your stuff.
});
Received a notice from server. The goal of these notices is to allow the users to change their language settings and still be able to know programmatically what message was sent by the server. We encourage to use the msg-id to compare these messages.
Parameters:
channel: String - Channel namemsgid: String - Message ID (See known msg-ids below)message: String - Message receivedKnown msg-ids:
already_banned: X is already banned in this room.already_subs_off: This room is not in subscribers-only mode.bad_ban_admin: You cannot ban admin X.bad_ban_broadcaster: You cannot ban the broadcaster.bad_ban_global_mod: You cannot ban global moderator X.bad_ban_self: You cannot ban yourself.bad_ban_staff: You cannot ban staff X.bad_commercial_error: Failed to start commercial.bad_mod_banned: X is banned in this room.bad_timeout_admin: You cannot timeout admin X.bad_timeout_global_mod: You cannot timeout global moderator X.bad_timeout_self: You cannot timeout yourself.bad_timeout_staff: You cannot timeout staff X.bad_unban_no_ban: X is not banned from this room.ban_success: X is now banned from this room.cmds_available: Commands available to you in this room (use /help for details)..color_changed: Your color has been changed.commercial_success: Initiating X second commercial break. Please keep in mind..hosts_remaining: X host commands remaining this half hour.host_target_went_offline: X has gone offline. Exiting host modemsg_banned: You are permanently banned from talking in channel.msg_duplicate: Your message was not sent because you are sending messages too quickly.msg_ratelimit: Your message was not sent because you are sending messages too quickly.msg_subsonly: This room is in subscribers only mode. To talk, purchase..msg_timedout: You are banned from talking in X for Y more seconds.msg_verified_email: This room requires a verified email address to chat.no_help: No help available.no_permission: You don't have permission to perform that action.timeout_success: X has been timed out for length seconds.unban_success: X is no longer banned from this room.unrecognized_cmd: Unrecognized command: Xusage_ban: Usage: "/ban " - Permanently prevent a user from chatting..usage_clear: Usage: "/clear" - Clear chat history for all users in this room.usage_color: Usage: "/color usage_commercial: Usage: "/commercial [length]" - Triggers a commercial.usage_disconnect: Usage: "/disconnect" - Reconnects to chat.usage_help: Usage: "/help" - Lists the commands available to you in this room.usage_host: Usage: "/host " - Host another channel. Use "unhost" to unset host mode.usage_me: Usage: "/me " - Send an "emote" message in the third person.usage_mod: Usage: "/mod " - Grant mod status to a user. Use "mods" to list the..usage_mods: Usage: "/mods" - Lists the moderators of this channel.usage_r9k_on: Usage: "/r9kbeta" - Enables r9k mode. See http://bit.ly/bGtBDf for details.usage_r9k_off: Usage: "/r9kbetaoff" - Disables r9k mode.usage_slow_on: Usage: "/slow [duration]" - Enables slow mode..usage_slow_off: Usage: "/slowoff" - Disables slow mode.usage_subs_on: Usage: "/subscribers" - Enables subscribers-only mode..usage_subs_off: Usage: "/subscribersoff" - Disables subscribers-only mode.usage_timeout: Usage: "/timeout [duration]" - Temporarily prevent a user from chatting.usage_unban: Usage: "/unban " - Removes a ban on a user.usage_unhost: Usage: "/unhost" - Stop hosting another channel.usage_unmod: Usage: "/unmod " - Revoke mod status from a user..whisper_invalid_self: You cannot whisper to yourself.whisper_limit_per_min: You are sending whispers too fast. Try again in a minute.whisper_limit_per_sec: You are sending whispers too fast. Try again in a second.whisper_restricted_recipient: That user's settings prevent them from receiving this whisper.The following msg-ids wont be returned in the notice event because they are already available as event listeners:
host_off: Exited hosting mode.host_on: Now hosting Xno_mods: There are no moderators for this room.r9k_off: This room is no longer in r9k mode.r9k_on: This room is now in r9k mode.room_mods: The moderators of this room are Xslow_off: This room is no longer in slow mode.slow_on: This room is now in slow mode. You may send messages every X seconds.subs_off: This room is no longer in subscribers-only mode.subs_on: This room is now in subscribers-only mode.client.on("notice", function (channel, msgid, message) {
// Do your stuff.
});
User has left a channel.
Parameters:
channel: String - Channel nameusername: String - Usernameclient.on("part", function (channel, username) {
// Do your stuff.
});
Received PING from server.
client.on("ping", function () {
// Do your stuff.
});
Sent a PING request ? PONG.
Parameters:
latency: Float - Current latencyclient.on("pong", function (latency) {
// Do your stuff.
});
Channel enabled or disabled R9K mode.
Parameters:
channel: String - Channel nameenabled: Boolean - Returns true if mode is enabled or false if disabledclient.on("r9kbeta", function (channel, enabled) {
// Do your stuff.
});
Trying to reconnect to server.
client.on("reconnect", function () {
// Do your stuff.
});
Triggered upon joining a channel. Gives you the current state of the channel.
Parameters:
channel: String - Channel namestate: Object - Current state of the channelclient.on("roomstate", function (channel, state) {
// Do your stuff.
});
According to Twitch, the state object is always subject to change.
{
'broadcaster-lang': null,
r9k: false,
slow: false,
'subs-only': false,
channel: '#schmoopiie'
}
Channel enabled or disabled slow mode.
Parameters:
channel: String - Channel nameenabled: Boolean - Returns true if mode is enabled or false if disabledlength: Integer - Slow length valueclient.on("slowmode", function (channel, enabled, length) {
// Do your stuff.
});
Username has shared how many months he/she has been a subscriber on a channel.
Parameters:
channel: String - Channel nameusername: String - Usernamemonths: Integer - How many monthsclient.on("subanniversary", function (channel, username, months) {
// Do your stuff.
});
Channel enabled or disabled subscribers-only mode.
Parameters:
channel: String - Channel nameenabled: Boolean - Returns true if mode is enabled or false if disabledclient.on("subscribers", function (channel, enabled) {
// Do your stuff.
});
Username has subscribed to a channel.
Parameters:
channel: String - Channel nameusername: String - Usernameclient.on("subscription", function (channel, username) {
// Do your stuff.
});
Username has been timed out on a channel.
Parameters:
channel: String - Channel nameusername: String - Usernameclient.on("timeout", function (channel, username) {
// Do your stuff.
});
Channel ended the current hosting.
Parameters:
channel: String - Channel nameviewers: Integer - Viewer countclient.on("unhost", function (channel, viewers) {
// Do your stuff.
});
Someone got unmodded on a channel.
Important: It doesn't detect if username got removed from moderators list. You will see a lot of mod / unmod events on a channel. When a moderator joins a channel, it will take a few seconds for jtv to give the user the moderator status. When leaving a channel, the user gets unmodded.
Parameters:
channel: String - Channel nameusername: String - Usernameclient.on("unmod", function (channel, username) {
// Do your stuff.
});
Received a whisper.
Important: You have to be connected to a group chat server to send or receive whispers.
Parameters:
username: String - Usernamemessage: String - Messageclient.on("whisper", function (username, message) {
// Do your stuff.
});