1
0
Fork 0
mirror of synced 2024-06-29 03:30:57 +12:00

Changed up error checking for if a hero isn't found/not used

This commit is contained in:
Phxntxm 2016-08-05 10:14:04 -05:00
parent 2e775e12d4
commit 34e0496e36

View file

@ -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