Appearance
HasChatMethods
php
trait Zairakai\LaravelTwitch\Services\Concerns\HasChatMethodsTwitch Chat API methods.
Requires user access token with appropriate chat scopes.
Source: src/Services/Concerns/HasChatMethods.php
Methods
clearChat()
php
public function clearChat(string $broadcasterId, string $moderatorId): voidClear all messages in a broadcaster's chat.
deleteMessage()
php
public function deleteMessage(string $broadcasterId, string $moderatorId, string $messageId = null): voidDelete a specific chat message or clear the entire chat.
| Parameter | Description |
|---|---|
$messageId | Specific message to delete; null clears all chat |
getChannelBadges()
php
public function getChannelBadges(string $broadcasterId): DataCollectionGet the broadcaster's custom chat badges.
Returns DataCollection<int, Badge>
getChannelEmotes()
php
public function getChannelEmotes(string $broadcasterId): DataCollectionGet all emotes for a broadcaster's channel.
Returns DataCollection<int, Emote>
getChatSettings()
php
public function getChatSettings(string $broadcasterId, string $moderatorId = null): ChatSettingsGet current chat settings for a broadcaster's channel.
getChatters()
php
public function getChatters(string $broadcasterId, string $moderatorId, int $first = 100, string $after = null): PaginatedResultGet the list of users currently in the broadcaster's chat.
Returns PaginatedResult<Chatter>
getEmoteSets()
php
public function getEmoteSets(string|array $emoteSetIds): DataCollectionGet emote information for one or more specified emote sets.
| Parameter | Description |
|---|---|
$emoteSetIds | One or more emote set IDs |
Returns DataCollection<int, Emote>
getGlobalBadges()
php
public function getGlobalBadges(): DataCollectionGet Twitch's global chat badges.
Returns DataCollection<int, Badge>
getGlobalEmotes()
php
public function getGlobalEmotes(): DataCollectionGet all global Twitch emotes.
Returns DataCollection<int, Emote>
getPinnedMessage()
php
public function getPinnedMessage(string $broadcasterId, string $moderatorId): PinnedChatMessageGet the broadcaster's currently mod-pinned chat message, if any.
getSharedChatSession()
php
public function getSharedChatSession(string $broadcasterId): SharedChatSessionGet the active shared chat session for a channel.
getUserChatColor()
php
public function getUserChatColor(string|array $userIds): DataCollectionGet the color used for the user's name in chat.
| Parameter | Description |
|---|---|
$userIds | One or more user IDs (max 100) |
Returns DataCollection<int, ChatColor>
getUserEmotes()
php
public function getUserEmotes(string $userId, string $broadcasterId = null, string $after = null): PaginatedResultGet emotes available to the user across all channels they follow/subscribe to.
Returns PaginatedResult<Emote>
pinMessage()
php
public function pinMessage(string $broadcasterId, string $moderatorId, string $messageId, int $durationSeconds = null): voidPins a chat message to the top of the broadcaster's chat room. Only one mod-pinned message can be active per channel - pinning a new one automatically replaces any existing pin.
| Parameter | Description |
|---|---|
$durationSeconds | How long to pin for, 30-1800 seconds. Omit to pin until the stream ends. |
sendAnnouncement()
php
public function sendAnnouncement(string $broadcasterId, string $moderatorId, string $message, string $color = 'PRIMARY'): voidSend a colored announcement to the broadcaster's chat.
| Parameter | Description |
|---|---|
$color | BLUE, GREEN, ORANGE, PURPLE, or PRIMARY |
sendMessage()
php
public function sendMessage(string $broadcasterId, string $senderId, string $message, string $replyParentMessageId = null, bool $pin = null): SentMessageSend a message to a broadcaster's chat.
| Parameter | Description |
|---|---|
$replyParentMessageId | ID of message to reply to |
$pin | Send and pin in one call - requires moderator:manage:chat_messages, sender must be the broadcaster or a moderator, always pins for 20 minutes (not configurable via this endpoint). Added 2026-05-15 alongside the open-beta pin/unpin endpoints (Pin Chat Message, Get/Update Pinned Chat Message, Unpin Chat Message) - those four are NOT implemented here, Twitch's own reference page never rendered their exact request/response shape even via three independent lookup attempts, and no third-party Twitch API client had them either as of 2026-08-27. Confirmed only via the changelog entry and Twitch's own dev forum, both of which describe the parameter but not the pin/unpin bodies - deliberately not guessing an unverified shape. |
sendShoutout()
php
public function sendShoutout(string $fromBroadcasterId, string $toBroadcasterId, string $moderatorId): voidSend a shoutout to another broadcaster.
unpinMessage()
php
public function unpinMessage(string $broadcasterId, string $moderatorId, string $messageId): voidUnpins a pinned chat message before its timer/stream-end would have.
updateChatSettings()
php
public function updateChatSettings(string $broadcasterId, string $moderatorId, UpdateChatSettingsRequest $updateChatSettingsRequest): ChatSettingsUpdate chat settings for a broadcaster's channel.
updatePinnedMessage()
php
public function updatePinnedMessage(string $broadcasterId, string $moderatorId, string $messageId, int $durationSeconds = null): voidUpdates the duration of an already-pinned chat message, starting from now.
| Parameter | Description |
|---|---|
$durationSeconds | New duration, 30-1800 seconds. Omit to pin until the stream ends. |
updateUserChatColor()
php
public function updateUserChatColor(string $userId, string $color): voidUpdate the color used for the user's name in chat.
| Parameter | Description |
|---|---|
$color | Named color (blue, blue_violet, cadet_blue, chocolate, coral, dodger_blue, firebrick, golden_rod, green, hot_pink, orange_red, red, sea_green, spring_green, yellow_green) or hex (#RRGGBB for Turbo/Prime) |