mirror of
https://github.com/stijndcl/didier.git
synced 2026-04-07 15:48:29 +02:00
Add slash command, support multiple restos & add date to embed
This commit is contained in:
parent
aae5616488
commit
73cc6aa0e9
4 changed files with 95 additions and 22 deletions
|
|
@ -1,4 +1,5 @@
|
|||
from data import schedule
|
||||
from data.embeds.food import Menu
|
||||
from decorators import help
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
|
|
@ -21,27 +22,7 @@ class School(commands.Cog):
|
|||
# @commands.check(checks.allowedChannels)
|
||||
@help.Category(category=Category.School)
|
||||
async def eten(self, ctx, day: str = None):
|
||||
day_dt = les.find_target_date(day if day else None)
|
||||
day_dt = skip_weekends(day_dt)
|
||||
day = intToWeekday(day_dt.weekday())
|
||||
|
||||
# Create embed
|
||||
menu = eten.etenScript(day_dt)
|
||||
embed = discord.Embed(colour=discord.Colour.blue())
|
||||
embed.set_author(name="Menu voor {}".format(day.lower()))
|
||||
|
||||
if "gesloten" in menu[0].lower():
|
||||
embed.description = "Restaurant gesloten"
|
||||
else:
|
||||
embed.add_field(name="🥣 Soep:", value=menu[0], inline=False)
|
||||
embed.add_field(name="🍴 Hoofdgerechten:", value=menu[1], inline=False)
|
||||
|
||||
if menu[2]:
|
||||
embed.add_field(name="❄️ Koud:", value=menu[2], inline=False)
|
||||
|
||||
if menu[3]:
|
||||
embed.add_field(name="🥦 Groenten:", value=menu[3], inline=False)
|
||||
|
||||
embed = Menu(day).to_embed()
|
||||
await ctx.reply(embed=embed, mention_author=False)
|
||||
|
||||
@commands.command(name="Les", aliases=["Class", "Classes", "Sched", "Schedule"], usage="[Dag]*")
|
||||
|
|
|
|||
37
cogs/slash/school_slash.py
Normal file
37
cogs/slash/school_slash.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
from discord.ext import commands
|
||||
from dislash import SlashInteraction, slash_command, Option, OptionType, OptionChoice
|
||||
|
||||
from data.embeds.food import Menu, restos
|
||||
from startup.didier import Didier
|
||||
|
||||
|
||||
class SchoolSlash(commands.Cog):
|
||||
def __init__(self, client: Didier):
|
||||
self.client: Didier = client
|
||||
|
||||
@slash_command(
|
||||
name="eten",
|
||||
description="Menu voor een bepaalde resto 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()
|
||||
await interaction.reply(embed=embed)
|
||||
|
||||
|
||||
def setup(client: Didier):
|
||||
client.add_cog(SchoolSlash(client))
|
||||
Loading…
Add table
Add a link
Reference in a new issue