From f052885ae016055a4077b2728043791ec2d889e2 Mon Sep 17 00:00:00 2001 From: Stijn De Clercq Date: Fri, 5 Nov 2021 23:36:12 +0100 Subject: [PATCH] Fix food api url, remove resto option --- cogs/slash/school_slash.py | 18 +++++------------- data/embeds/food.py | 2 +- functions/eten.py | 4 ++-- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/cogs/slash/school_slash.py b/cogs/slash/school_slash.py index d664f99..e94a562 100644 --- a/cogs/slash/school_slash.py +++ b/cogs/slash/school_slash.py @@ -1,7 +1,7 @@ from discord.ext import commands -from dislash import SlashInteraction, slash_command, Option, OptionType, OptionChoice +from dislash import SlashInteraction, slash_command, Option, OptionType -from data.embeds.food import Menu, restos +from data.embeds.food import Menu from startup.didier import Didier @@ -11,25 +11,17 @@ class SchoolSlash(commands.Cog): @slash_command( name="eten", - description="Menu voor een bepaalde resto op een bepaalde dag", + description="Menu in de UGENT resto's op een bepaalde dag", options=[ Option( "dag", description="Dag", type=OptionType.STRING - ), - Option( - "resto", - description="Resto", - type=OptionType.STRING, - choices=list( - OptionChoice(v, k) for k, v in restos.items() - ) ) ] ) - async def _food_slash(self, interaction: SlashInteraction, dag: str = None, resto: str = "sterre"): - embed = Menu(dag, resto).to_embed() + async def _food_slash(self, interaction: SlashInteraction, dag: str = None): + embed = Menu(dag).to_embed() await interaction.reply(embed=embed) diff --git a/data/embeds/food.py b/data/embeds/food.py index 65d2519..78aeb45 100644 --- a/data/embeds/food.py +++ b/data/embeds/food.py @@ -38,7 +38,7 @@ class Menu: embed = discord.Embed(colour=discord.Colour.blue()) date_formatted = f"{lz(self._day.day)}/{lz(self._day.month)}/{self._day.year}" embed.set_author(name=f"Menu voor {self.day.lower()} {date_formatted}") - embed.title = f"Resto {restos[self.resto]}" + # embed.title = f"Resto {restos[self.resto]}" if "gesloten" in self._menu[0].lower(): embed.description = "Restaurant gesloten" diff --git a/functions/eten.py b/functions/eten.py index 1d6220b..e025fea 100644 --- a/functions/eten.py +++ b/functions/eten.py @@ -24,7 +24,7 @@ def get_type(menu: Dict, type_: str) -> str: return acc -def etenScript(dag: datetime, resto: str = "sterre"): +def etenScript(dag: datetime): # What day menuSoep = "" menuHoofdgerechten = "" @@ -33,7 +33,7 @@ def etenScript(dag: datetime, resto: str = "sterre"): # Fetch from API try: - menu = requests.get(f"https://zeus.ugent.be/hydra/api/2.0/resto/menu/nl-{resto}/{dag.year}/{dag.month}/{dag.day}.json").json() + menu = requests.get(f"https://zeus.ugent.be/hydra/api/2.0/resto/menu/nl/{dag.year}/{dag.month}/{dag.day}.json").json() if not menu["meals"]: raise Exception()