diff --git a/pages/index.tsx b/pages/index.tsx index 3c6802a..abb0291 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -21,17 +21,14 @@ function Home() { let base_url = emote.data.host.url; // get the largest emote size, append it to the base url let largest = emote.data.host.files[emote.data.host.files.length - 1]; - // if width != height, skip it - if (largest.width !== largest.height) { - return null; + // could be null + if (!largest || largest.width !== largest.height) { + return false; } + return `https:${base_url}/${largest.name}`; }); - // remove null values - - emoteUrls = emoteUrls.filter((emote: any) => emote !== null); - setEmotes(emoteUrls); setCurrentEmote(Math.floor(Math.random() * emoteUrls.length)); }); diff --git a/pages/user/[username]/index.tsx b/pages/user/[username]/index.tsx index 660115d..e3db5f8 100644 --- a/pages/user/[username]/index.tsx +++ b/pages/user/[username]/index.tsx @@ -55,6 +55,10 @@ function UserPage(props: UserPageProps) { let base_url = emote.data.host.url; // get the largest emote size, append it to the base url let largest = emote.data.host.files[emote.data.host.files.length - 1]; + // if null return + if (!largest) { + return false; + } emotes["7tv"][emote.data.name] = `https:${base_url}/${largest.name}`; }); // same for global emotes