flapjax / FlapJack-Cogs

Custom cogs for Red Bot
MIT License
36 stars 38 forks source link

[Blizzard] Overwatch Stats KeyError #36

Closed ShibePrime closed 7 years ago

ShibePrime commented 7 years ago
[27/07/2017` 20:21] ERROR red on_command_error 369: Exception in command 'overwatch stats'
Traceback (most recent call last):
  File "lib\discord\ext\commands\core.py", line 50, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "C:\Users\andrew\Documents\ShibeBot\Red-DiscordBot\cogs\blizzard.py", line 212, in _stats_overwatch
    '\n**Avg Dmg:** ', str(int(round(comp['average_stats']['damage_done_avg']))),
KeyError: 'damage_done_avg'

Something isn't quite right here. Posting here as a reminder to help figure out what's going on.

flapjax commented 7 years ago

Thanks, also putting this here for future reference, reported by Andeh#6603 on 07/19/2017


Traceback (most recent call last):
  File "lib/discord/ext/commands/core.py", line 50, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "/home/ubuntu/Red-DiscordBot/cogs/blizzard.py", line 302, in _stats_overwatch
    if stats[region] is None:
KeyError: 'na'
flapjax commented 7 years ago

Sorry, my comment was unrelated. The problem is average damage was removed from the API. So I am removing it as well.

flapjax commented 7 years ago

The other keyerror problem occurs when a bad region is entered. In this case, you need to use 'us' instead of 'na'. I've made a small change so the bot responds with a message if a bad region is entered. Both issues are fixed. Closing!