From 32cdc4cbf63f5513f6a38e16f5a22daf6dee6886 Mon Sep 17 00:00:00 2001 From: jonz94 Date: Thu, 12 Dec 2024 16:57:34 +0800 Subject: [PATCH] feat(parser): Update `LiveChatBanner` * Mark `viewerIsCreator` property as optional * Mark `background_type` property as optional * Add `banner_type` property * Add `banner_properties_is_ephemeral` property * Add `banner_properties_auto_collapse_delay_seconds` property --- .../classes/livechat/items/LiveChatBanner.ts | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/parser/classes/livechat/items/LiveChatBanner.ts b/src/parser/classes/livechat/items/LiveChatBanner.ts index 9243920ed..c4db8c8e7 100644 --- a/src/parser/classes/livechat/items/LiveChatBanner.ts +++ b/src/parser/classes/livechat/items/LiveChatBanner.ts @@ -9,19 +9,46 @@ export default class LiveChatBanner extends YTNode { header: LiveChatBannerHeader | null; contents: YTNode; action_id: string; - viewer_is_creator: boolean; + viewer_is_creator?: boolean; target_id: string; is_stackable: boolean; - background_type: string; + background_type?: string; + banner_type: string; + banner_properties_is_ephemeral?: boolean; + banner_properties_auto_collapse_delay_seconds?: string; constructor(data: RawNode) { super(); this.header = Parser.parseItem(data.header, LiveChatBannerHeader); this.contents = Parser.parseItem(data.contents); this.action_id = data.actionId; - this.viewer_is_creator = data.viewerIsCreator; + + if (Reflect.has(data, 'viewerIsCreator')) { + this.viewer_is_creator = data.viewerIsCreator; + } + this.target_id = data.targetId; this.is_stackable = data.isStackable; - this.background_type = data.backgroundType; + + if (Reflect.has(data, 'backgroundType')) { + this.background_type = data.backgroundType; + } + + this.banner_type = data.bannerType; + + if ( + Reflect.has(data, 'bannerProperties') && + Reflect.has(data.bannerProperties, 'isEphemeral') + ) { + this.banner_properties_is_ephemeral = Boolean(data.bannerProperties.isEphemeral); + } + + if ( + Reflect.has(data, 'bannerProperties') && + Reflect.has(data.bannerProperties, 'autoCollapseDelay') && + Reflect.has(data.bannerProperties.autoCollapseDelay, 'seconds') + ) { + this.banner_properties_auto_collapse_delay_seconds = data.bannerProperties.autoCollapseDelay.seconds; + } } } \ No newline at end of file