From cbe1cf747fd595fa046662cb313b4117781a2214 Mon Sep 17 00:00:00 2001 From: Stijn De Clercq Date: Thu, 19 Aug 2021 19:45:00 +0200 Subject: [PATCH] Fix error in food --- cogs/school.py | 1 + functions/eten.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cogs/school.py b/cogs/school.py index 29f8ec0..828f0a8 100644 --- a/cogs/school.py +++ b/cogs/school.py @@ -29,6 +29,7 @@ class School(commands.Cog): menu = eten.etenScript(day) embed = discord.Embed(colour=discord.Colour.blue()) embed.set_author(name="Menu voor {}".format(day)) + if "gesloten" in menu[0].lower(): embed.description = "Restaurant gesloten" else: diff --git a/functions/eten.py b/functions/eten.py index e95d2d2..30354ce 100644 --- a/functions/eten.py +++ b/functions/eten.py @@ -26,7 +26,11 @@ def etenScript(weekDag): # Fetch from API try: - menu = requests.get("https://zeus.ugent.be/hydra/api/2.0/resto/menu/nl-sterre/{}/{}/{}.json".format(d.year, d.month, d.day)).json() + menu = requests.get(f"https://zeus.ugent.be/hydra/api/2.0/resto/menu/nl-sterre/{d.year}/{d.month}/{d.day}.json").json() + + if not menu["meals"]: + raise Exception() + # Print menu for s in menu["meals"]: @@ -49,4 +53,4 @@ def etenScript(weekDag): menuSoep += "Restaurant gesloten" menuGroenten += "Restaurant gesloten" menuHoofdgerechten += "Restaurant gesloten" - return (menuSoep, menuHoofdgerechten, menuGroenten) \ No newline at end of file + return menuSoep, menuHoofdgerechten, menuGroenten