Catch keyerror for corona vaccines

pull/100/head
Stijn De Clercq 2021-11-29 21:55:07 +01:00
parent c84cb3f944
commit 13df55ac53
1 changed files with 9 additions and 1 deletions

View File

@ -32,7 +32,10 @@ class Corona(commands.Cog):
return
# Vaccination stats
try:
vaccine = self.getVaccineData(country, dic["today"]["population"], dic["yesterday"]["population"])
except KeyError:
vaccine = None
await self.sendEmbed(ctx, dic, vaccine)
@ -210,6 +213,11 @@ class Corona(commands.Cog):
embed.add_field(name="Aantal toegediende vaccins:",
value="{:,}".format(vaccines["today"]["vaccines"]),
inline=False)
else:
# Vaccine data is missing
embed.add_field(name="Aantal toegediende vaccins:",
value="?",
inline=False)
# Timestamp of last update
timeFormatted = timeFormatters.epochToDate(int(dic["today"]["updated"]) / 1000)