Skip to content

Commit

Permalink
fix: handle invalid banner header
Browse files Browse the repository at this point in the history
  • Loading branch information
uetchy committed May 26, 2022
1 parent b6decce commit 37ed5f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/chat/actions/addBannerToLiveChatCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ export function parseAddBannerToLiveChatCommand(
// add pinned item
const bannerRdr = payload["bannerRenderer"]["liveChatBannerRenderer"];

if (!bannerRdr.header) {
throw new Error(
"[action required] Invalid banner header: " + JSON.stringify(bannerRdr)
);
}

if (bannerRdr.header.liveChatBannerHeaderRenderer.icon.iconType !== "KEEP") {
debugLog(
"[action required] unknown icon type (addBannerToLiveChatCommand)",
"[action required] Unknown icon type (addBannerToLiveChatCommand)",
JSON.stringify(bannerRdr.header.liveChatBannerHeaderRenderer.icon)
);
}
Expand Down Expand Up @@ -40,7 +46,7 @@ export function parseAddBannerToLiveChatCommand(

if (!authorName) {
debugLog(
"[action required] empty authorName at addBannerToLiveChatCommand",
"[action required] Empty authorName found at addBannerToLiveChatCommand",
JSON.stringify(liveChatRdr)
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/yt/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export interface YTLiveChatBannerRenderer {
actionId: string;
targetId: string; // live-chat-banner
contents: YTLiveChatTextMessageRendererContainer;
header: YTLiveChatBannerRendererHeader;
header?: YTLiveChatBannerRendererHeader;
viewerIsCreator: boolean;
}

Expand Down

0 comments on commit 37ed5f0

Please sign in to comment.