1
0
Fork 0
mirror of synced 2024-05-20 12:32:26 +12:00

Catch if we can't connect to OW API

This commit is contained in:
Phxntxm 2017-03-19 18:02:34 -05:00
parent c2b20a9a29
commit 8f4421e6a1

View file

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