chat - YoYoGames/GMEXT-Twitch GitHub Wiki

Chat

Functions

These are the functions of this module:



Back To Top

twitch_chat_get_chatters

Twitch Endpoint: func_name

This function gets the list of users that are connected to the broadcaster's chat session.

Note

There is a delay between when users join and leave a chat and when the list is updated accordingly.

To determine whether a user is a moderator or VIP, use twitch_moderation_get_moderators and twitch_moderation_get_vips. You can check the roles of up to 100 users.

Note

Requires a user access token that includes the TWITCH_SCOPE: TWITCH_SCOPE_MODERATOR_READ_CHATTERS.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_chat_get_chatters(broadcaster_id, moderator_id, optionals, callback_success, callback_failed)
Argument Type Description
broadcaster_id String The ID of the broadcaster whose list of chatters you want to get.
moderator_id String The ID of the broadcaster or one of the broadcaster's moderators. This ID must match the user ID in the user access token.
optionals Struct The optional parameters to be passed into the function:

- first : Real : The maximum number of items to return per page in the response. The minimum page size is 1 item per page and the maximum is 1,000. The default is 100.
- after : String : The cursor used to get the next page of results. The Pagination struct in the response contains the cursor's value. Read more
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
data Array The list of users that are connected to the broadcaster's chat room. The list is empty if no users are connected to the chat room.
 β”œβ”€β”€ user_id String The ID of a user that's connected to the broadcaster's chat room.
 β”œβ”€β”€ user_login String The user's login name.
 β””── user_name String The user's display name.
pagination Struct Contains the information used to page through the list of results. The struct is empty if there are no more pages left to page through. Read More
 β””── cursor String The cursor used to get the next page of results. Use the cursor to set the request's after parameter.
total Real The total number of users that are connected to the broadcaster's chat room. As you page through the list, the number of users may change as users join and leave the chat room.

Failure Callback

This method is triggered on failure.




Back To Top

twitch_chat_get_channel_emotes

Twitch Endpoint: Get Channel Emotes

This function gets the broadcaster's list of custom emotes. Broadcasters create these custom emotes for users who subscribe to or follow the channel or cheer Bits in the channel's chat window. Learn More

For information about the custom emotes, see subscriber emotes, Bits tier emotes, and follower emotes.

Note

With the exception of custom follower emotes, users may use custom emotes in any Twitch chat.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_chat_get_channel_emotes(broadcaster_id, callback_success, callback_failed)
Argument Type Description
broadcaster_id String An ID that identifies the broadcaster whose emotes you want to get.
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
data Array The list of emotes that the specified broadcaster created. If the broadcaster hasn't created custom emotes, the list is empty.
 β”œβ”€β”€ id String An ID that identifies this emote.
 β”œβ”€β”€ name String The name of the emote. This is the name that viewers type in the chat window to get the emote to appear.
 β”œβ”€β”€ images Struct The image URLs for the emote. These image URLs always provide a static, non-animated emote image with a light background. NOTE: You should use the templated URL in the template field to fetch the image instead of using these URLs.
         β”œβ”€β”€ url_1x String A URL to the small version (28px x 28px) of the emote.
         β”œβ”€β”€ url_2x String A URL to the medium version (56px x 56px) of the emote.
         β””── url_4x String A URL to the large version (112px x 112px) of the emote.
 β”œβ”€β”€ tier String The subscriber tier at which the emote is unlocked. This field contains the tier information only if emote_type is set to "subscriptions", otherwise, it's an empty string.
 β”œβ”€β”€ emote_type String The type of emote. The possible values are: "bitstier" β€” A custom Bits tier emote, "follower" β€” A custom follower emote, "subscriptions" β€” A custom subscriber emote.
 β”œβ”€β”€ emote_set_id String An ID that identifies the emote set that the emote belongs to.
 β”œβ”€β”€ format Array of String The formats that the emote is available in. For example, if the emote is available only as a static PNG, the array contains only "static". But if the emote is available as a static PNG and an animated GIF, the array contains "static" and "animated". The possible formats are: "animated" β€” An animated GIF is available for this emote, "static" β€” A static PNG file is available for this emote.
 β”œβ”€β”€ scale Array of String The sizes that the emote is available in. For example, if the emote is available in small and medium sizes, the array contains 1.0 and 2.0. Possible sizes are: 1.0 β€” A small version (28px x 28px) is available, 2.0 β€” A medium version (56px x 56px) is available, 3.0 β€” A large version (112px x 112px) is available.
 β””── theme_mode Array of String The background themes that the emote is available in. Possible themes are: "dark", "light"
template String A templated URL. Use the values from the id, format, scale, and theme_mode fields to replace the like-named placeholder strings in the templated URL to create a CDN (content delivery network) URL that you use to fetch the emote. For information about what the template looks like and how to use it to fetch emotes, see Emote CDN URL format. You should use this template instead of using the URLs in the images struct.

Failure Callback

This method is triggered on failure.




Back To Top

twitch_chat_get_global_emotes

Twitch Endpoint: Get Global Emotes

This function gets the list of global emotes. Global emotes are Twitch-created emotes that users can use in any Twitch chat.

Learn More

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_chat_get_global_emotes(callback_success, callback_failed)
Argument Type Description
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
data Array The list of global emotes.
 β”œβ”€β”€ id String An ID that identifies this emote.
 β”œβ”€β”€ name String The name of the emote. This is the name that viewers type in the chat window to get the emote to appear.
 β”œβ”€β”€ images Struct The image URLs for the emote. These image URLs always provide a static, non-animated emote image with a light background. NOTE: You should use the templated URL in the template field to fetch the image instead of using these URLs.
         β”œβ”€β”€ url_1x String A URL to the small version (28px x 28px) of the emote.
         β”œβ”€β”€ url_2x String A URL to the medium version (56px x 56px) of the emote.
         β””── url_4x String A URL to the large version (112px x 112px) of the emote.
 β”œβ”€β”€ format Array of String The formats that the emote is available in. For example, if the emote is available only as a static PNG, the array contains only "static". But if the emote is available as a static PNG and an animated GIF, the array contains "static" and "animated". The possible formats are: "animated" β€” An animated GIF is available for this emote, "static" β€” A static PNG file is available for this emote.
 β”œβ”€β”€ scale Array of String The sizes that the emote is available in. For example, if the emote is available in small and medium sizes, the array contains 1.0 and 2.0. Possible sizes are:1.0 β€” A small version (28px x 28px) is available.2.0 β€” A medium version (56px x 56px) is available.3.0 β€” A large version (112px x 112px) is available.
 β””── theme_mode Array of String The background themes that the emote is available in. Possible themes are: "dark", "light"
template String A templated URL. Use the values from the id, format, scale, and theme_mode fields to replace the like-named placeholder strings in the templated URL to create a CDN (content delivery network) URL that you use to fetch the emote. For information about what the template looks like and how to use it to fetch emotes, see Emote CDN URL format. You should use this template instead of using the URLs in the images struct.

Failure Callback

This method is triggered on failure.




Back To Top

twitch_chat_get_emote_sets

Twitch Endpoint: Get Emote Sets

This function gets emotes for one or more specified emote sets.

An emote set groups emotes that have a similar context. For example, Twitch places all the subscriber emotes that a broadcaster uploads for their channel in the same emote set.

Learn More

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_chat_get_emote_sets(emote_set_id, callback_success, callback_failed)
Argument Type Description
emote_set_id String or Array An ID that identifies the emote set to get. Pass an array of IDs to specify multiple emote sets. You may specify a maximum of 25 IDs. The response contains only the IDs that were found and ignores duplicate IDs. To get emote set IDs, use twitch_chat_get_channel_emotes.
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
data Array The list of emotes found in the specified emote sets. The list is empty if none of the IDs were found. The list is in the same order as the set IDs specified in the request. Each set contains one or more emoticons.
 β”œβ”€β”€ id String An ID that uniquely identifies this emote.
 β”œβ”€β”€ name String The name of the emote. This is the name that viewers type in the chat window to get the emote to appear.
 β”œβ”€β”€ images Struct The image URLs for the emote. These image URLs always provide a static, non-animated emote image with a light background. NOTE: You should use the templated URL in the template field to fetch the image instead of using these URLs.
         β”œβ”€β”€ url_1x String A URL to the small version (28px x 28px) of the emote.
         β”œβ”€β”€ url_2x String A URL to the medium version (56px x 56px) of the emote.
         β””── url_4x String A URL to the large version (112px x 112px) of the emote.
 β”œβ”€β”€ emote_type String The type of emote. The possible values are: "bitstier" - A Bits tier emote, "follower" - A follower emote, "subscriptions" - A subscriber emote.
 β”œβ”€β”€ emote_set_id String An ID that identifies the emote set that the emote belongs to.
 β”œβ”€β”€ owner_id String The ID of the broadcaster who owns the emote.
 β”œβ”€β”€ format Array of String The formats that the emote is available in. For example, if the emote is available only as a static PNG, the array contains only "static". But if the emote is available as a static PNG and an animated GIF, the array contains "static" and "animated". The possible formats are: "animated" - An animated GIF is available for this emote, "static" - A static PNG file is available for this emote.
 β”œβ”€β”€ scale Array of String The sizes that the emote is available in. For example, if the emote is available in small and medium sizes, the array contains 1.0 and 2.0. Possible sizes are: 1.0 - A small version (28px x 28px) is available, 2.0 - A medium version (56px x 56px) is available, 3.0 - A large version (112px x 112px) is available.
 β””── theme_mode Array of String The background themes that the emote is available in. Possible themes are: "dark", "light"
template String A templated URL. Use the values from the id, format, scale, and theme_mode fields to replace the like-named placeholder strings in the templated URL to create a CDN (content delivery network) URL that you use to fetch the emote. For information about what the template looks like and how to use it to fetch emotes, see Emote CDN URL format. You should use this template instead of using the URLs in the images struct.

Failure Callback

This method is triggered on failure.




Back To Top

twitch_chat_get_channel_chat_badges

Twitch Endpoint: Get Channel Chat Badges

This function gets the broadcaster's list of custom chat badges. The list is empty if the broadcaster hasn't created custom chat badges. For information about custom badges, see subscriber badges and Bits badges.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_chat_get_channel_chat_badges(broadcaster_id, callback_success, callback_failed)
Argument Type Description
broadcaster_id String The ID of the broadcaster whose chat badges you want to get.
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
data Array The list of chat badges. The list is sorted in ascending order by set_id, and within a set, the list is sorted in ascending order by id.
 β”œβ”€β”€ set_id String An ID that identifies this set of chat badges. For example, Bits or Subscriber.
 β””── versions Array The list of chat badges in this set.
         β”œβ”€β”€ id String An ID that identifies this version of the badge. The ID can be any value. For example, for Bits, the ID is the Bits tier level, but for World of Warcraft, it could be Alliance or Horde.
         β”œβ”€β”€ image_url_1x String A URL to the small version (18px x 18px) of the badge.
         β”œβ”€β”€ image_url_2x String A URL to the medium version (36px x 36px) of the badge.
         β”œβ”€β”€ image_url_4x String A URL to the large version (72px x 72px) of the badge.
         β”œβ”€β”€ title String The title of the badge.
         β”œβ”€β”€ description String The description of the badge.
         β”œβ”€β”€ click_action String The action to take when clicking on the badge. Set to undefined if no action is specified.
         β””── click_url String The URL to navigate to when clicking on the badge. Set to undefined if no URL is specified.

Failure Callback

This method is triggered on failure.




Back To Top

twitch_chat_get_global_chat_badges

Twitch Endpoint: Get Global Chat Badges

This function gets Twitch's list of chat badges, which users may use in any channel's chat room. For information about chat badges, see Twitch Chat Badges Guide.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_chat_get_global_chat_badges(callback_success, callback_failed)
Argument Type Description
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
data Array The list of chat badges. The list is sorted in ascending order by set_id, and within a set, the list is sorted in ascending order by id.
 β”œβ”€β”€ set_id String An ID that identifies this set of chat badges. For example, Bits or Subscriber.
 β””── versions Array The list of chat badges in this set.
         β”œβ”€β”€ id String An ID that identifies this version of the badge. The ID can be any value. For example, for Bits, the ID is the Bits tier level, but for World of Warcraft, it could be Alliance or Horde.
         β”œβ”€β”€ image_url_1x String A URL to the small version (18px x 18px) of the badge.
         β”œβ”€β”€ image_url_2x String A URL to the medium version (36px x 36px) of the badge.
         β”œβ”€β”€ image_url_4x String A URL to the large version (72px x 72px) of the badge.
         β”œβ”€β”€ title String The title of the badge.
         β”œβ”€β”€ description String The description of the badge.
         β”œβ”€β”€ click_action String The action to take when clicking on the badge. Set to undefined if no action is specified.
         β””── click_url String The URL to navigate to when clicking on the badge. Set to undefined if no URL is specified.

Failure Callback

This method is triggered on failure.




Back To Top

twitch_chat_get_chat_settings

Twitch Endpoint: Get Chat Settings

This function gets the broadcaster's chat settings.

For an overview of chat settings, see Chat Commands for Broadcasters and Moderators and Moderator Preferences.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_chat_get_chat_settings(broadcaster_id, optionals, callback_success, callback_failed)
Argument Type Description
broadcaster_id String The ID of the broadcaster whose chat settings you want to get.
optionals Struct The optional parameters to be passed into the function:

- moderator_id : String : The ID of the broadcaster or one of the broadcaster's moderators. This field is required only if you want to include the non_moderator_chat_delay and non_moderator_chat_delay_duration settings in the response. If you specify this field, this ID must match the user ID in the user access token.
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
data Array The list of chat settings. It contains a single struct with all the settings.
 β”œβ”€β”€ broadcaster_id String The ID of the broadcaster specified in the request.
 β”œβ”€β”€ emote_mode Boolean A Boolean value that determines whether chat messages must contain only emotes. Is true if chat messages may contain only emotes; otherwise, false.
 β”œβ”€β”€ follower_mode Boolean A Boolean value that determines whether the broadcaster restricts the chat room to followers only. Is true if the broadcaster restricts the chat room to followers only; otherwise, false. See the follower_mode_duration field for how long users must follow the broadcaster before being able to participate in the chat room.
 β”œβ”€β”€ follower_mode_duration Real The length of time, in minutes, that users must follow the broadcaster before being able to participate in the chat room. Is undefined if follower_mode is false.
 β”œβ”€β”€ moderator_id String The moderator's ID. The response includes this field only if the request specifies a user access token that includes the TWITCH_SCOPE: TWITCH_SCOPE_MODERATION_READ_CHAT_SETTINGS.
 β”œβ”€β”€ non_moderator_chat_delay Boolean A Boolean value that determines whether the broadcaster adds a short delay before chat messages appear in the chat room. This gives chat moderators and bots a chance to remove them before viewers can see the message. See the non_moderator_chat_delay_duration field for the length of the delay. Is true if the broadcaster applies a delay; otherwise, false. The response includes this field only if the request specifies a user access token that includes the TWITCH_SCOPE: TWITCH_SCOPE_MODERATION_READ_CHAT_SETTINGS and the user in the moderator_id parameter is one of the broadcaster's moderators.
 β”œβ”€β”€ non_moderator_chat_delay_duration Real The amount of time, in seconds, that messages are delayed before appearing in chat. Is undefined if non_moderator_chat_delay is false.The response includes this field only if the request specifies a user access token that includes the TWITCH_SCOPE: TWITCH_SCOPE_MODERATOR_READ_CHAT_SETTINGS and the user in the moderator_id parameter is one of the broadcaster's moderators.
 β”œβ”€β”€ slow_mode Boolean A Boolean value that determines whether the broadcaster limits how often users in the chat room are allowed to send messages. Is true if the broadcaster applies a delay; otherwise, false. See the slow_mode_wait_time field for the delay.
 β”œβ”€β”€ slow_mode_wait_time Real The amount of time, in seconds, that users must wait between sending messages. Is undefined if slow_mode is false.
 β”œβ”€β”€ subscriber_mode Boolean A Boolean value that determines whether only users that subscribe to the broadcaster's channel may talk in the chat room. Is true if the broadcaster restricts the chat room to subscribers only; otherwise, false.
 β””── unique_chat_mode Boolean A Boolean value that determines whether the broadcaster requires users to post only unique messages in the chat room. Is true if the broadcaster requires unique messages only; otherwise, false.

Failure Callback

This method is triggered on failure.




Back To Top

twitch_chat_get_user_emotes

Twitch Endpoint: Get User Emotes

This function retrieves emotes available to the user across all channels.

Note

Requires a user access token that includes the TWITCH_SCOPE: TWITCH_SCOPE_USER_READ_EMOTES.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_chat_get_user_emotes(user_id, optionals, callback_success, callback_failed)
Argument Type Description
user_id String The ID of the user. This ID must match the user ID in the user access token.
optionals Struct The optional parameters to be passed into the function:

- after : String : The cursor used to get the next page of results. The Pagination struct in the response contains the cursor's value.
- broadcaster_id : String : The User ID of a broadcaster you wish to get follower emotes of. Using this parameter will guarantee inclusion of the broadcaster's follower emotes in the response body. Note: If the user specified in user_id is subscribed to the broadcaster specified, their follower emotes will appear in the response body regardless if this parameter is used.
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
data Array
 β”œβ”€β”€ id String An ID that uniquely identifies this emote.
 β”œβ”€β”€ name String The User ID of broadcaster whose channel is receiving the unban request.
 β”œβ”€β”€ emote_type String The type of emote. The possible values are: "none" β€” No emote type was assigned to this emote, "bitstier" β€” A Bits tier emote, "follower" β€” A follower emote, "subscriptions" β€” A subscriber emote, "channelpoints" β€” An emote granted by using channel points, "rewards" β€” An emote granted to the user through a special event, "hypetrain" β€” An emote granted for participation in a Hype Train, "prime" β€” An emote granted for linking an Amazon Prime account, "turbo" β€” An emote granted for having Twitch Turbo, "smilies" β€” Emoticons supported by Twitch, "globals" β€” An emote accessible by everyone, "owl2019" β€” Emotes related to Overwatch League 2019, "twofactor" β€” Emotes granted by enabling two-factor authentication on an account, "limitedtime" β€” Emotes that were granted for only a limited time.
 β”œβ”€β”€ emote_set_id String An ID that identifies the emote set that the emote belongs to.
 β”œβ”€β”€ owner_id String The ID of the broadcaster who owns the emote.
 β”œβ”€β”€ format Array of String The formats that the emote is available in. For example, if the emote is available only as a static PNG, the array contains only "static". But if the emote is available as a static PNG and an animated GIF, the array contains "static" and "animated". "animated" β€” An animated GIF is available for this emote, "static" β€” A static PNG file is available for this emote.
 β”œβ”€β”€ scale Array of String The sizes that the emote is available in. For example, if the emote is available in small and medium sizes, the array contains 1.0 and 2.0. 1.0 β€” A small version (28px x 28px) is available, 2.0 β€” A medium version (56px x 56px) is available, 3.0 β€” A large version (112px x 112px) is available.
 β””── theme_mode Array of String The background themes that the emote is available in: "dark", "light"
template String A templated URL. Uses the values from the id, format, scale, and theme_mode fields to replace the like-named placeholder strings in the templated URL to create a CDN (content delivery network) URL that you use to fetch the emote. For information about what the template looks like and how to use it to fetch emotes, see Emote CDN URL format.
pagination Struct Contains the information used to page through the list of results. The struct is empty if there are no more pages left to page through. For more information about pagination support, see Twitch API Guide - Pagination.
 β””── cursor String The cursor used to get the next page of results. Use the cursor to set the request's after parameter.

Failure Callback

This method is triggered on failure.




Back To Top

twitch_chat_live_connect

Twitch Endpoint: N / A

This function creates a connection to be used with the Chat functions.

The function takes a callback function with a single parameter: the Buffer that holds the received data.

See the Twitch documentation on IRC Concepts for information on how to parse IRC messages.


Syntax:

twitch_chat_live_connect(channel_id, nickname, callback)
Argument Type Description
channel_id String The ID of the channel to connect to
nickname String The nickname to use
callback Function The callback function that receives the data



Returns:

N/A




Back To Top

twitch_chat_live_disconnect

Twitch Endpoint: N / A

This function disconnects from the connection set up earlier using twitch_chat_live_connect.

Note

This function frees the underlying web socket and must be called when you're finished using the connection to prevent a memory leak.


Syntax:

twitch_chat_live_disconnect()



Returns:

N/A




Back To Top

twitch_chat_live_send

Twitch Endpoint: N / A

This function sends a chat message to a channel's chat room.

See the Twitch documentation on Sending Messages for information on the possibilities.


Syntax:

twitch_chat_live_send(text)
Argument Type Description
text String The message to send



Returns:

N/A




Back To Top

twitch_chat_live_send_raw

Twitch Endpoint: N / A

This function sends a raw live chat message.

See the Twitch documentation on IRC Concepts for information on IRC messages.


Syntax:

twitch_chat_live_send_raw(text)
Argument Type Description
text String The raw message to send



Returns:

N/A




Back To Top

twitch_chat_update_chat_settings

Twitch Endpoint: Update Chat Settings

This function updates the broadcaster's chat settings.

Note

Requires a user access token that includes the TWITCH_SCOPE: TWITCH_SCOPE_MODERATOR_MANAGE_CHAT_SETTINGS.

To set the slow_mode_wait_time or follower_mode_duration field to its default value, set the corresponding slow_mode or follower_mode field to true (and don't include the slow_mode_wait_time or follower_mode_duration field).

To set the slow_mode_wait_time, follower_mode_duration, or non_moderator_chat_delay_duration field's value, you must set the corresponding slow_mode, follower_mode, or non_moderator_chat_delay field to true.

To remove the slow_mode_wait_time, follower_mode_duration, or non_moderator_chat_delay_duration field's value, set the corresponding slow_mode, follower_mode, or non_moderator_chat_delay field to false (and don't include the slow_mode_wait_time, follower_mode_duration, or non_moderator_chat_delay_duration field).

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_chat_update_chat_settings(broadcaster_id, moderator_id, optionals, callback_success, callback_failed)
Argument Type Description
broadcaster_id String The ID of the broadcaster whose chat settings you want to update.
moderator_id String The ID of a user that has permission to moderate the broadcaster's chat room, or the broadcaster's ID if they're making the update. This ID must match the user ID in the user access token.
optionals Struct The optional parameters to be passed into the function:

- emote_mode : Boolean : A Boolean value that determines whether chat messages must contain only emotes.
Set to true if only emotes are allowed; otherwise, false. The default is false.
- follower_mode : Boolean : A Boolean value that determines whether the broadcaster restricts the chat room to followers only.
Set to true if the broadcaster restricts the chat room to followers only; otherwise, false. The default is true.
To specify how long users must follow the broadcaster before being able to participate in the chat room, see the follower_mode_duration field.
- follower_mode_duration : Boolean : The length of time, in minutes, that users must follow the broadcaster before being able to participate in the chat room. Set only if follower_mode is true. Possible values are: 0 (no restriction) through 129600 (3 months). The default is 0.
- non_moderator_chat_delay : Boolean : A Boolean value that determines whether the broadcaster adds a short delay before chat messages appear in the chat room. This gives chat moderators and bots a chance to remove them before viewers can see the message.
Set to true if the broadcaster applies a delay; otherwise, false. The default is false.
To specify the length of the delay, see the non_moderator_chat_delay_duration field.
- non_moderator_chat_delay_duration : Real : The amount of time, in seconds, that messages are delayed before appearing in chat. Set only if non_moderator_chat_delay is true. Possible values are:
* 2 - 2 second delay (recommended)
* 4 - 4 second delay
* 6 - 6 second delay
- slow_mode : Boolean : A Boolean value that determines whether the broadcaster limits how often users in the chat room are allowed to send messages. Set to true if the broadcaster applies a wait period between messages; otherwise, false. The default is false.
To specify the delay, see the slow_mode_wait_time field.
- slow_mode_wait_time : Real : The amount of time, in seconds, that users must wait between sending messages. Set only if slow_mode is true.
Possible values are: 3 (3 second delay) through 120 (2 minute delay). The default is 30 seconds.
- subscriber_mode : Boolean : A Boolean value that determines whether only users that subscribe to the broadcaster’s channel may talk in the chat room.
Set to true if the broadcaster restricts the chat room to subscribers only; otherwise, false. The default is false.
- unique_chat_mode : Boolean : A Boolean value that determines whether the broadcaster requires users to post only unique messages in the chat room.
Set to true if the broadcaster allows only unique messages; otherwise, false. The default is false.
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
emote_mode Boolean A Boolean value that determines whether chat messages must contain only emotes. Set to true if only emotes are allowed; otherwise, false. The default is false.
follower_mode Boolean A Boolean value that determines whether the broadcaster restricts the chat room to followers only. Set to true if the broadcaster restricts the chat room to followers only; otherwise, false. The default is true. To specify how long users must follow the broadcaster before being able to participate in the chat room, see the follower_mode_duration field.
follower_mode_duration Real The length of time, in minutes, that users must follow the broadcaster before being able to participate in the chat room. Set only if follower_mode is true. Possible values are: 0 (no restriction) through 129600 (3 months). The default is 0.
non_moderator_chat_delay Boolean A Boolean value that determines whether the broadcaster adds a short delay before chat messages appear in the chat room. This gives chat moderators and bots a chance to remove them before viewers can see the message. Set to true if the broadcaster applies a delay; otherwise, false. The default is false. To specify the length of the delay, see the non_moderator_chat_delay_duration field.
non_moderator_chat_delay_duration Real The amount of time, in seconds, that messages are delayed before appearing in chat. Set only if non_moderator_chat_delay is true. Possible values are: 2 - 2 second delay (recommended), 4 - 4 second delay, 6 - 6 second delay
slow_mode Boolean A Boolean value that determines whether the broadcaster limits how often users in the chat room are allowed to send messages. Set to true if the broadcaster applies a wait period between messages; otherwise, false. The default is false.To specify the delay, see the slow_mode_wait_time field.
slow_mode_wait_time Real The amount of time, in seconds, that users must wait between sending messages. Set only if slow_mode is true. Possible values are: 3 (3 second delay) through 120 (2 minute delay). The default is 30 seconds.
subscriber_mode Boolean A Boolean value that determines whether only users that subscribe to the broadcaster's channel may talk in the chat room. Set to true if the broadcaster restricts the chat room to subscribers only; otherwise, false. The default is false.
unique_chat_mode Boolean A Boolean value that determines whether the broadcaster requires users to post only unique messages in the chat room. Set to true if the broadcaster allows only unique messages; otherwise, false. The default is false.
data Array The list of chat settings. The list contains a single struct with all the settings.
 β”œβ”€β”€ broadcaster_id String The ID of the broadcaster specified in the request.
 β”œβ”€β”€ emote_mode Boolean A Boolean value that determines whether chat messages must contain only emotes. Is true if chat messages may contain only emotes; otherwise, false.
 β”œβ”€β”€ follower_mode Boolean A Boolean value that determines whether the broadcaster restricts the chat room to followers only. Is true if the broadcaster restricts the chat room to followers only; otherwise, false. See the follower_mode_duration field for how long users must follow the broadcaster before being able to participate in the chat room.
 β”œβ”€β”€ follower_mode_duration Real The length of time, in minutes, that users must follow the broadcaster before being able to participate in the chat room. Is undefined if follower_mode is false.
 β”œβ”€β”€ moderator_id String The moderator's ID. The response includes this field only if the request specifies a user access token that includes the TWITCH_SCOPE: TWITCH_SCOPE_MODERATOR_READ_CHAT_SETTINGS.
 β”œβ”€β”€ non_moderator_chat_delay Boolean A Boolean value that determines whether the broadcaster adds a short delay before chat messages appear in the chat room. This gives chat moderators and bots a chance to remove them before viewers can see the message. See the non_moderator_chat_delay_duration field for the length of the delay. Is true if the broadcaster applies a delay; otherwise, false.
 β”œβ”€β”€ non_moderator_chat_delay_duration Real The amount of time, in seconds, that messages are delayed before appearing in chat. Is undefined if non_moderator_chat_delay is false.
 β”œβ”€β”€ slow_mode Boolean A Boolean value that determines whether the broadcaster limits how often users in the chat room are allowed to send messages. Is true if the broadcaster applies a delay; otherwise, false. See the slow_mode_wait_time field for the delay.
 β”œβ”€β”€ slow_mode_wait_time Real The amount of time, in seconds, that users must wait between sending messages. Is undefined if slow_mode is false.
 β”œβ”€β”€ subscriber_mode Boolean A Boolean value that determines whether only users that subscribe to the broadcaster's channel may talk in the chat room. Is true if the broadcaster restricts the chat room to subscribers only; otherwise, false.
 β””── unique_chat_mode Boolean A Boolean value that determines whether the broadcaster requires users to post only unique messages in the chat room. Is true if the broadcaster requires unique messages only; otherwise, false.

Failure Callback

This method is triggered on failure.




Back To Top

twitch_chat_send_chat_announcement

Twitch Endpoint: Send Chat Announcement

This function sends an announcement to the broadcaster's chat room.

Note

Requires a user access token that includes the TWITCH_SCOPE: TWITCH_SCOPE_MODERATOR_MANAGE_ANNOUNCEMENTS.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_chat_send_chat_announcement(broadcaster_id, moderator_id, message, optionals, callback_success, callback_failed)
Argument Type Description
broadcaster_id String The ID of the broadcaster that owns the chat room to send the announcement to.
moderator_id String The ID of a user who has permission to moderate the broadcaster's chat room, or the broadcaster's ID if they're sending the announcement. This ID must match the user ID in the user access token.
message String The announcement to make in the broadcaster's chat room. Announcements are limited to a maximum of 500 characters; announcements longer than 500 characters are truncated.
optionals Struct The optional parameters to be passed into the function:

- color : String : The color used to highlight the announcement. Possible case-sensitive values are: "blue", "green", "orange", "purple", "primary" (default). If color is set to "primary" or is not set, the channel's accent color is used to highlight the announcement (see Profile Accent Color under profile settings, Channel and Videos, and Brand).
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

This method is triggered on success. It has no response body.


Failure Callback

This method is triggered on failure.




Back To Top

twitch_chat_send_a_shoutout

Twitch Endpoint: Send a Shoutout

This function sends a Shoutout to the specified broadcaster. Typically, you send Shoutouts when you or one of your moderators notice another broadcaster in your chat, the other broadcaster is coming up in conversation, or after they raid your broadcast.

Twitch's Shoutout feature is a great way for you to show support for other broadcasters and help them grow. Viewers who do not follow the other broadcaster will see a pop-up Follow button in your chat that they can click to follow the other broadcaster. Learn More

Rate Limits The broadcaster may send a Shoutout once every 2 minutes. They may send the same broadcaster a Shoutout once every 60 minutes.

To receive notifications when a Shoutout is sent or received, subscribe to the channel.shoutout.create and channel.shoutout.receive subscription types. The channel.shoutout.create event includes cooldown periods that indicate when the broadcaster may send another Shoutout without exceeding the endpoint's rate limit.

Note

Requires a user access token that includes the TWITCH_SCOPE: TWITCH_SCOPE_MODERATOR_MANAGE_SHOUTOUTS.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_chat_send_a_shoutout(from_broadcaster_id, to_broadcaster_id, moderator_id, callback_success, callback_failed)
Argument Type Description
from_broadcaster_id String The ID of the broadcaster that's sending the Shoutout.
to_broadcaster_id String The ID of the broadcaster that's receiving the Shoutout.
moderator_id String The ID of the broadcaster or a user that is one of the broadcaster's moderators. This ID must match the user ID in the access token.
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

This method is triggered on success. It has no response body.


Failure Callback

This method is triggered on failure.




Back To Top

twitch_chat_send_chat_message

Twitch Endpoint: Send Chat Message

This function sends a message to the broadcaster's chat room.

Note

Requires an app access token or user access token that includes the TWITCH_SCOPE_USER_WRITE_CHAT scope. If app access token used, then additionally requires TWITCH_SCOPE_USER_BOT scope from chatting user, and either TWITCH_SCOPE_CHANNEL_BOT scope from broadcaster or moderator status.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_chat_send_chat_message(broadcaster_id, sender_id, message, optionals, callback_success, callback_failed)
Argument Type Description
broadcaster_id String The ID of the broadcaster whose chat room the message will be sent to.
sender_id String The ID of the user sending the message. This ID must match the user ID in the user access token.
message String The message to send. The message is limited to a maximum of 500 characters. Chat messages can also include emoticons. To include emoticons, use the name of the emote. The names are case sensitive. Don't include colons around the name (e.g., ":bleedPurple:"). If Twitch recognizes the name, Twitch converts the name to the emote before writing the chat message to the chat room
optionals Struct The optional parameters to be passed into the function:

- reply_parent_message_id : String : The ID of the chat message being replied to.
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
data Array
 β”œβ”€β”€ message_id String The message id for the message that was sent.
 β”œβ”€β”€ is_sent Boolean If the message passed all checks and was sent.
 β””── drop_reason Struct The reason the message was dropped, if any.
         β”œβ”€β”€ code String Code for why the message was dropped.
         β””── message String Message for why the message was dropped.

Failure Callback

This method is triggered on failure.




Back To Top

twitch_chat_get_user_chat_color

Twitch Endpoint: Get User Chat Color

This function gets the color used for the user's name in chat.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_chat_get_user_chat_color(user_id, callback_success, callback_failed)
Argument Type Description
user_id Real or Array The ID of the user whose username color you want to get. To specify more than one user, pass an array with the ID of each user to get. The maximum number of IDs that you may specify is 100.The API ignores duplicate IDs and IDs that weren't found.
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

These members are returned in the success callback:

Member Type Description
data Array The list of users and the color code they use for their name.
 β”œβ”€β”€ user_id String An ID that uniquely identifies the user.
 β”œβ”€β”€ user_login String The user's login name.
 β”œβ”€β”€ user_name String The user's display name.
 β””── color String The Hex color code that the user uses in chat for their name. If the user hasn't specified a color in their settings, the string is empty.

Failure Callback

This method is triggered on failure.




Back To Top

twitch_chat_update_user_chat_color

Twitch Endpoint: Update User Chat Color

This function updates the color used for the user's name in chat.

Note

Requires a user access token that includes the TWITCH_SCOPE: TWITCH_SCOPE_USER_MANAGE_CHAT_COLOR.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.


Syntax:

twitch_chat_update_user_chat_color(user_id, color, callback_success, callback_failed)
Argument Type Description
user_id String The ID of the user whose chat color you want to update. This ID must match the user ID in the access token.
color String The color to use for the user's name in chat. All users may specify one of the following named color values: "blue", "blue_violet", "cadet_blue", "chocolate", "coral", "dodger_blue", "firebrick", "golden_rod", "green", "hot_pink", "orange_red", "red", "sea_green", "spring_green", "yellow_green". Turbo and Prime users may specify a named color or a Hex color code like "#9146FF". If you use a Hex color code, remember to URL encode it.
callback_success Function Triggered if the request succeeded
callback_failed Function Triggered if the request failed



Returns:

N/A


Triggers:

Success Callback

This method is triggered on success. It has no response body.


Failure Callback

This method is triggered on failure.



⚠️ **GitHub.com Fallback** ⚠️