Files
YouTube.js/src/parser/classes/livechat/items/LiveChatBannerPoll.ts
Chinmay Kumar cfc1a183e0 refactor(parser): type YTNodes' data arg as RawNode (wip) (#339)
* replaced YTNode's data arg as RawNode

* updated documentation

* removed unused import

---- Note that there are still many nodes that need to be updated, hence the WIP status.
2023-03-07 02:02:07 -03:00

36 lines
1.1 KiB
TypeScript

import { YTNode } from '../../../helpers.js';
import Parser from '../../../index.js';
import Text from '../../misc/Text.js';
import Thumbnail from '../../misc/Thumbnail.js';
import type { RawNode } from '../../../index.js';
class LiveChatBannerPoll extends YTNode {
static type = 'LiveChatBannerPoll';
poll_question: Text;
author_photo: Thumbnail[];
choices: {
option_id: string;
text: string;
}[];
collapsed_state_entity_key: string;
live_chat_poll_state_entity_key: string;
context_menu_button;
constructor(data: RawNode) {
super();
this.poll_question = new Text(data.pollQuestion);
this.author_photo = Thumbnail.fromResponse(data.authorPhoto);
this.choices = data.pollChoices.map((choice: any) => ({
option_id: choice.pollOptionId,
text: new Text(choice.text).toString()
}));
this.collapsed_state_entity_key = data.collapsedStateEntityKey;
this.live_chat_poll_state_entity_key = data.liveChatPollStateEntityKey;
this.context_menu_button = Parser.parseItem(data.contextMenuButton);
}
}
export default LiveChatBannerPoll;