TwitchChatRequests

Inherits: TwitchRequestBase < RefCounted < Object

Twitch Chat API for messages, emotes, badges, and chat settings.

Description

TwitchChatRequests provides comprehensive methods for interacting with Twitch chat including sending messages, managing emotes and badges, configuring chat settings, and sending announcements. Requires various OAuth scopes depending on the operation. Access through TwitchAPI.get_chat().

Tutorials

Methods

void

get_channel_chat_badges(broadcaster_id: String)

void

get_channel_emotes(broadcaster_id: String)

void

get_chat_settings(broadcaster_id: String, moderator_id: String = "")

void

get_chatters(broadcaster_id: String, moderator_id: String, params: Dictionary = {})

void

get_emote_sets(emote_set_id: String)

void

get_global_chat_badges()

void

get_global_emotes()

void

get_user_chat_color(user_id: String)

void

get_user_emotes(user_id: String, broadcaster_id: String = "")

void

send_a_shoutout(from_broadcaster_id: String, to_broadcaster_id: String, moderator_id: String)

void

send_chat_announcement(broadcaster_id: String, moderator_id: String, message: String, color: String = "")

void

send_chat_message(broadcaster_id: String, sender_id: String, message: String, reply_parent_message_id: String = "")

void

update_chat_settings(broadcaster_id: String, moderator_id: String, settings: Dictionary)

void

update_user_chat_color(user_id: String, color: String)


Method Descriptions

void get_channel_chat_badges(broadcaster_id: String) 🔗

Gets the broadcaster's custom chat badges. Results are returned via the TwitchAPI.request_completed signal with signal_name "channel_chat_badges_received".

Response includes: Array of badge sets with set_id, versions (id, image_url_1x/2x/4x, title, description, click_action, click_url).

TwitchAPI.get_chat().get_channel_chat_badges("broadcaster_id")
# Response: {"data": [{"set_id": "subscriber", "versions": [{"id": "1", "image_url_1x": "https://...", "title": "Subscriber", "description": "1-Month Subscriber"}]}]}

void get_channel_emotes(broadcaster_id: String) 🔗

Gets the broadcaster's custom emotes including subscriber emotes. Results are returned via the TwitchAPI.request_completed signal with signal_name "channel_emotes_received".

Response includes: Array of emotes with id, name, images (url_1x/2x/4x), tier, emote_type, emote_set_id, format, scale, theme_mode.

TwitchAPI.get_chat().get_channel_emotes("broadcaster_id")
# Response: {"data": [{"id": "emotesv2_abc123", "name": "MyEmote", "images": {"url_1x": "...", "url_2x": "...", "url_4x": "..."}, "tier": "1000", "emote_type": "subscriptions"}]}

void get_chat_settings(broadcaster_id: String, moderator_id: String = "") 🔗

Gets the chat settings for a broadcaster's channel including emote-only mode, follower mode, slow mode, and subscriber mode. Results are returned via the TwitchAPI.request_completed signal with signal_name "chat_settings_received".

Response includes: broadcaster_id, emote_mode, follower_mode, follower_mode_duration, non_moderator_chat_delay, non_moderator_chat_delay_duration, slow_mode, slow_mode_wait_time, subscriber_mode, unique_chat_mode.

TwitchAPI.get_chat().get_chat_settings("broadcaster_id")
# Response: {"data": [{"broadcaster_id": "123", "emote_mode": false, "follower_mode": true, "follower_mode_duration": 10, "slow_mode": false, "subscriber_mode": false}]}

void get_chatters(broadcaster_id: String, moderator_id: String, params: Dictionary = {}) 🔗

Gets the list of users currently connected to the broadcaster's chat. Optional params can include first. Requires moderator:read:chatters scope. Results are returned via the TwitchAPI.request_completed signal with signal_name "chatters_received".

Response includes: Array of chatters with user_id, user_login, user_name; total chatter count.

TwitchAPI.get_chat().get_chatters("broadcaster_id", "moderator_id", {"first": 100})
# Response: {"data": [{"user_id": "123", "user_login": "viewer1", "user_name": "Viewer1"}], "total": 1523}

void get_emote_sets(emote_set_id: String) 🔗

Gets emotes from one or more specified emote sets. Results are returned via the TwitchAPI.request_completed signal with signal_name "emote_sets_received".

Response includes: Array of emotes (same structure as get_channel_emotes).

TwitchAPI.get_chat().get_emote_sets("emote_set_id_123")
# Response: {"data": [{"id": "emotesv2_abc", "name": "MyEmote", "images": {"url_1x": "https://..."}}]}

void get_global_chat_badges() 🔗

Gets Twitch's global chat badges available to all users. Results are returned via the TwitchAPI.request_completed signal with signal_name "global_chat_badges_received".

Response includes: Array of badge sets (same structure as get_channel_chat_badges).

TwitchAPI.get_chat().get_global_chat_badges()
# Response: {"data": [{"set_id": "moderator", "versions": [{"id": "1", "image_url_1x": "https://...", "title": "Moderator"}]}]}

void get_global_emotes() 🔗

Gets all global emotes available to all Twitch users. Results are returned via the TwitchAPI.request_completed signal with signal_name "global_emotes_received".

Response includes: Array of emotes (same structure as get_channel_emotes).

TwitchAPI.get_chat().get_global_emotes()
# Response: {"data": [{"id": "emotesv2_global", "name": "Kappa", "images": {"url_1x": "https://..."}, "format": ["static"], "scale": ["1.0", "2.0", "3.0"]}]}

void get_user_chat_color(user_id: String) 🔗

Gets the color used for the user's name in chat. Results are returned via the TwitchAPI.request_completed signal with signal_name "user_chat_color_received".

Response includes: user_id, user_login, user_name, color (hex code or named color).

TwitchAPI.get_chat().get_user_chat_color("user_id")
# Response: {"data": [{"user_id": "123", "user_login": "username", "user_name": "UserName", "color": "#FF0000"}]}

void get_user_emotes(user_id: String, broadcaster_id: String = "") 🔗

Gets emotes available to the user across all channels. Optional broadcaster_id filters to emotes from a specific broadcaster. Requires user:read:emotes scope. Results are returned via the TwitchAPI.request_completed signal with signal_name "user_emotes_received".

Response includes: Array of emotes (same structure as get_channel_emotes).

TwitchAPI.get_chat().get_user_emotes("user_id", "broadcaster_id")
# Response: {"data": [{"id": "emotesv2_123", "name": "SubEmote", "emote_type": "subscriptions", "emote_set_id": "300374282"}]}

void send_a_shoutout(from_broadcaster_id: String, to_broadcaster_id: String, moderator_id: String) 🔗

Sends a Shoutout to the specified broadcaster. Requires moderator:manage:shoutouts scope. Results are returned via the TwitchAPI.request_completed signal with signal_name "shoutout_sent".

Response: Returns 204 No Content on success.

TwitchAPI.get_chat().send_a_shoutout("from_broadcaster_id", "to_broadcaster_id", "moderator_id")
# Response: 204 No Content on success

void send_chat_announcement(broadcaster_id: String, moderator_id: String, message: String, color: String = "") 🔗

Sends an announcement to the broadcaster's chat room. Optional color can be blue, green, orange, purple, or primary. Requires moderator:manage:announcements scope. Results are returned via the TwitchAPI.request_completed signal with signal_name "chat_announcement_sent".

Response: Returns 204 No Content on success.

TwitchAPI.get_chat().send_chat_announcement("broadcaster_id", "moderator_id", "Stream starting soon!", "purple")
# Response: 204 No Content on success

void send_chat_message(broadcaster_id: String, sender_id: String, message: String, reply_parent_message_id: String = "") 🔗

Sends a message to the broadcaster's chat room. Optional reply_parent_message_id makes this a reply. Requires user:write:chat scope. Results are returned via the TwitchAPI.request_completed signal with signal_name "chat_message_sent".

Response includes: message_id, is_sent (bool), drop_reason (code, message) if message was dropped.

TwitchAPI.get_chat().send_chat_message("broadcaster_id", "sender_id", "Hello from Blazium!")
# Response: {"data": [{"message_id": "msg-id-123", "is_sent": true}]}

void update_chat_settings(broadcaster_id: String, moderator_id: String, settings: Dictionary) 🔗

Updates the broadcaster's chat settings. settings can include emote_mode, follower_mode, slow_mode, subscriber_mode, and related durations. Requires moderator:manage:chat_settings scope. Results are returned via the TwitchAPI.request_completed signal with signal_name "chat_settings_updated".

Response includes: Updated chat settings object (same structure as get_chat_settings).

var settings = {"slow_mode": true, "slow_mode_wait_time": 30}
TwitchAPI.get_chat().update_chat_settings("broadcaster_id", "moderator_id", settings)
# Response: {"data": [{"broadcaster_id": "123", "slow_mode": true, "slow_mode_wait_time": 30, ...}]}

void update_user_chat_color(user_id: String, color: String) 🔗

Updates the color used for the user's name in chat. color can be a named color (blue, coral, dodger_blue, etc.) or a hex code. Requires user:manage:chat_color scope. Results are returned via the TwitchAPI.request_completed signal with signal_name "user_chat_color_updated".

Response: Returns 204 No Content on success.

TwitchAPI.get_chat().update_user_chat_color("user_id", "blue")
# Or with hex: TwitchAPI.get_chat().update_user_chat_color("user_id", "#FF0000")
# Response: 204 No Content on success