From 34e0496e36d89146e2f868ab461428957d7631bf Mon Sep 17 00:00:00 2001 From: Phxntxm Date: Fri, 5 Aug 2016 10:14:04 -0500 Subject: [PATCH] Changed up error checking for if a hero isn't found/not used --- cogs/overwatch.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cogs/overwatch.py b/cogs/overwatch.py index 9beb906..0737301 100644 --- a/cogs/overwatch.py +++ b/cogs/overwatch.py @@ -55,11 +55,13 @@ class Overwatch: url = base_url + "{}/heroes/{}".format(bt, hero.lower().replace('-', '')) with aiohttp.ClientSession(headers={"User-Agent": "Bonfire/1.0.0"}) as s: async with s.get(url) as r: - if r.status == 500: + result = await r.text() + msg = json.loads(result)['msg'] + if msg = 'hero data not found' fmt = "{} has not used the hero {} before!".format(user.name, hero.title()) await self.bot.say(fmt) return - elif r.status == 404: + elif msg == 'bad hero name': fmt = "{} is not an actual hero!".format(hero.title()) await self.bot.say(fmt) return