mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-13 09:32:12 +00:00
Live Chat
Represents a livestream chat.
Usage
Before fetching a live chat, you have to retrieve the target livestream's info:
const info = await yt.getInfo('video_id');
Then you may request a live chat instance:
const livechat = await info.getLiveChat();
API
- LiveChat
- .ev ⇒
EventEmitter - .start ⇒
function - .stop ⇒
function - .applyFilter ⇒
function - .getItemMenu ⇒
function - .sendMessage ⇒
function
- .ev ⇒
ev
Live Chat's EventEmitter.
Events:
-
startFired when the live chat is started.
Arguments:
Type Description LiveChatContinuationInitial chat data, actions, info, etc. -
chat-updateFired when a new chat action is received.
Arguments:
Type Description ChatActionChat action -
metadata-updateFired when the livestream's metadata is updated.
Arguments:
Type Description LiveMetadataLivestream metadata -
errorFired when an error occurs.
Arguments:
Type Description ErrorDetails about the error -
endFired when the livestream ends.
start()
Starts the Live Chat.
stop()
Stops the Live Chat.
applyFilter(filter)
Applies given filter to the live chat.
| Param | Type | Description |
|---|---|---|
| filter | string |
Can be TOP_CHAT or LIVE_CHAT |
getItemMenu(item)
Retrieves given chat item's menu.
| Param | Type | Description |
|---|---|---|
| item | object |
Chat item |
Returns: Promise<ItemMenu>
sendMessage(text)
Sends a message.
| Param | Type | Description |
|---|---|---|
| text | string |
Message content |
Returns: Promise<ObservedArray<AddChatItemAction>>
Example
See index.ts.