From 430aa86e6ac25f1eb6d603204722c1e45bd76a0b Mon Sep 17 00:00:00 2001 From: Phxntxm Date: Sun, 10 Jul 2016 10:50:12 -0500 Subject: [PATCH] Added error handling for if the twitch user does not exist --- cogs/twitch.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cogs/twitch.py b/cogs/twitch.py index 2c1fb22..0a177d0 100644 --- a/cogs/twitch.py +++ b/cogs/twitch.py @@ -32,7 +32,13 @@ class Twitch: url="https://www.twitch.tv/{}".format(url) else: url="https://www.{}".format(url) - + + try: + urllib.request.urlopen(url) + except urllib.request.HTTPError: + await self.bot.say("That twitch user does not exist! What would be the point of adding a nonexistant twitch user? Silly") + return + cursor = config.getCursor() cursor.execute('use {}'.format(config.db_default)) cursor.execute('select twitch_url from twitch where user_id="{}"'.format(ctx.message.author.id))