From 9f97f107bc1b3476b252fd157fbc6e047c487ea1 Mon Sep 17 00:00:00 2001 From: phxntxm Date: Tue, 27 Jun 2017 19:13:14 -0500 Subject: [PATCH] Add a check for if the url given is None --- cogs/twitch.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cogs/twitch.py b/cogs/twitch.py index 069ca8a..d1df451 100644 --- a/cogs/twitch.py +++ b/cogs/twitch.py @@ -46,7 +46,11 @@ class Twitch: return embed - async def online_embed(self, twitch_url: str): + async def online_embed(self, twitch_url): + # First make sure the twitch URL is actually given + if not twitch_url: + return None + # Check a specific channel's data, and get the response in text format channel = re.search("(?<=twitch.tv/)(.*)", twitch_url).group(1) url = "https://api.twitch.tv/kraken/streams/{}".format(channel) @@ -64,8 +68,11 @@ class Twitch: except (KeyError, TypeError): return None + async def offline_embed(self, twitch_url): + # First make sure the twitch URL is actually given + if not twitch_url: + return None - async def offline_embed(self, twitch_url: str): # Check a specific channel's data, and get the response in text format channel = re.search("(?<=twitch.tv/)(.*)", twitch_url).group(1) url = "https://api.twitch.tv/kraken/channels/{}".format(channel)