mirror of https://github.com/stijndcl/didier
Catch missing fields in menu
parent
9225f61e47
commit
b85f5a612a
|
@ -12,4 +12,5 @@ async def fetch_menu(http_session: ClientSession, day_dt: date) -> Menu:
|
|||
"""Fetch the menu for a given day"""
|
||||
endpoint = f"https://hydra.ugent.be/api/2.0/resto/menu/nl/{day_dt.year}/{day_dt.month}/{day_dt.day}.json"
|
||||
async with ensure_get(http_session, endpoint, log_exceptions=False) as response:
|
||||
print(response)
|
||||
return Menu.parse_obj(response)
|
||||
|
|
|
@ -94,12 +94,17 @@ class Menu(EmbedPydantic):
|
|||
return embed
|
||||
|
||||
def _regular_embed(self, embed: discord.Embed) -> discord.Embed:
|
||||
embed.add_field(name="🥣 Soep", value=self._get_soups(), inline=False)
|
||||
embed.add_field(name="🍴 Hoofdgerechten", value=self._get_main_courses(), inline=False)
|
||||
embed.add_field(name="❄️Koud", value=self._get_cold_meals(), inline=False)
|
||||
if soups := self._get_soups():
|
||||
embed.add_field(name="🥣 Soep", value=soups, inline=False)
|
||||
|
||||
vegetables = "\n".join(list(sorted(self.vegetables)))
|
||||
embed.add_field(name="🥦 Groenten", value=vegetables, inline=False)
|
||||
if mains := self._get_main_courses():
|
||||
embed.add_field(name="🍴 Hoofdgerechten", value=mains, inline=False)
|
||||
|
||||
if cold := self._get_cold_meals():
|
||||
embed.add_field(name="❄️Koud", value=cold, inline=False)
|
||||
|
||||
if vegetables := "\n".join(list(sorted(self.vegetables))):
|
||||
embed.add_field(name="🥦 Groenten", value=vegetables, inline=False)
|
||||
|
||||
return embed
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ from didier.utils.types.datetime import (
|
|||
str_to_weekday,
|
||||
)
|
||||
|
||||
__all__ = ["date_converter"]
|
||||
__all__ = ["date_converter", "DateTransformer"]
|
||||
|
||||
|
||||
def date_converter(argument: Optional[str]) -> date:
|
||||
|
@ -56,6 +56,7 @@ def date_converter(argument: Optional[str]) -> date:
|
|||
class DateTransformer(app_commands.Transformer):
|
||||
"""Application commands transformer for dates"""
|
||||
|
||||
@overrides
|
||||
async def autocomplete(
|
||||
self, interaction: discord.Interaction, value: Union[int, float, str]
|
||||
) -> list[app_commands.Choice[Union[int, float, str]]]:
|
||||
|
|
|
@ -2,7 +2,7 @@ aiohttp==3.8.1
|
|||
alembic==1.8.0
|
||||
asyncpg==0.25.0
|
||||
beautifulsoup4==4.11.1
|
||||
discord.py==2.0.0
|
||||
discord.py==2.0.1
|
||||
environs==9.5.0
|
||||
feedparser==6.0.10
|
||||
markdownify==0.11.2
|
||||
|
|
Loading…
Reference in New Issue