feat(parser): Update LiveChatBanner (#840)

* 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
This commit is contained in:
jonz94
2024-12-12 20:38:44 +08:00
committed by GitHub
parent 9a9bb76a92
commit 69d42b291c

View File

@@ -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;
}
}
}