From 13df55ac53ae23311592106febe04665a1698ce6 Mon Sep 17 00:00:00 2001 From: Stijn De Clercq Date: Mon, 29 Nov 2021 21:55:07 +0100 Subject: [PATCH] Catch keyerror for corona vaccines --- cogs/corona.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cogs/corona.py b/cogs/corona.py index 9cd35cc..82f93fa 100644 --- a/cogs/corona.py +++ b/cogs/corona.py @@ -32,7 +32,10 @@ class Corona(commands.Cog): return # Vaccination stats - vaccine = self.getVaccineData(country, dic["today"]["population"], dic["yesterday"]["population"]) + 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)