Skip to content

Commit

Permalink
feat(parser): Update LiveChatBanner (#840)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jonz94 authored Dec 12, 2024
1 parent 9a9bb76 commit 69d42b2
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions src/parser/classes/livechat/items/LiveChatBanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

0 comments on commit 69d42b2

Please sign in to comment.