From 8f4421e6a15f5db4ed16d96b76556a26605d1ac2 Mon Sep 17 00:00:00 2001 From: Phxntxm Date: Sun, 19 Mar 2017 18:02:34 -0500 Subject: [PATCH] Catch if we can't connect to OW API --- cogs/overwatch.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cogs/overwatch.py b/cogs/overwatch.py index 0dfc58c..6006da3 100644 --- a/cogs/overwatch.py +++ b/cogs/overwatch.py @@ -51,6 +51,10 @@ class Overwatch: # If no hero was provided, we just want the base stats for a player url = BASE_URL + "{}/stats".format(bt) data = await utils.request(url) + if data is None: + await ctx.send("I couldn't connect to overwatch at the moment!") + return + region = [x for x in data.keys() if data[x] is not None][0] stats = data[region]['stats']['quickplay'] @@ -61,6 +65,9 @@ class Overwatch: hero = hero.lower().replace('-', '') url = BASE_URL + "{}/heroes".format(bt) data = await utils.request(url) + if data is None: + await ctx.send("I couldn't connect to overwatch at the moment!") + return region = [x for x in data.keys() if data[x] is not None][0] stats = data[region]['heroes']['stats']['quickplay'].get(hero)