UNPKG

@twitchfy/chatbot

Version:

A powerful node module to make your own Twitch ChatBot

54 lines (53 loc) 1.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StreamOnline = void 0; const Base_1 = require("./Base"); const BaseStream_1 = require("./BaseStream"); const BaseUser_1 = require("./BaseUser"); /** * Represents a stream online event. */ class StreamOnline extends Base_1.Base { /** * The broadcaster of the channel whose stream went online. */ broadcaster; /** * The stream which went online. */ stream; /** * The data of the stream online event returned from the EventSub. */ data; /** * Creates a new instance of the stream online event. * @param chatbot The current instance of the chatbot. * @param data The data of the stream online event returned from the EventSub. */ constructor(chatbot, data) { super(chatbot); this.data = data; this.broadcaster = new BaseUser_1.BaseUser(chatbot, { ...data.broadcaster, display_name: data.broadcaster.displayName }); this.stream = new BaseStream_1.BaseStream(chatbot, { ...data.stream, started_at: data.stream.startedAt.toISOString(), user_id: data.broadcaster.id, user_login: data.broadcaster.login, user_name: data.broadcaster.displayName }); } /** * The Id of the broadcaster whose stream went online. */ get broadcasterId() { return this.data.broadcaster.id; } /** * The Id of the chatroom where the stream went online. */ get chatroomId() { return this.data.broadcaster.id; } /** * Returns the time when the stream went online. A JavaScript Date object is returned. */ get startedAt() { return this.data.stream.startedAt; } } exports.StreamOnline = StreamOnline;