2021-08-08 18:24:53 +02:00
|
|
|
from data import schedule
|
2021-11-29 21:37:04 +01:00
|
|
|
from data.embeds.deadlines import Deadlines
|
2021-09-26 22:12:52 +02:00
|
|
|
from data.embeds.food import Menu
|
2020-10-13 21:02:40 +02:00
|
|
|
from decorators import help
|
|
|
|
import discord
|
|
|
|
from discord.ext import commands
|
|
|
|
from enums.help_categories import Category
|
2021-11-29 21:37:04 +01:00
|
|
|
from functions import config, les
|
2021-08-08 18:33:32 +02:00
|
|
|
from functions.stringFormatters import capitalize
|
2021-11-29 21:37:04 +01:00
|
|
|
from functions.timeFormatters import skip_weekends
|
2020-10-13 21:02:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
class School(commands.Cog):
|
|
|
|
|
|
|
|
def __init__(self, client):
|
|
|
|
self.client = client
|
|
|
|
|
|
|
|
# Don't allow any commands to work when locked
|
|
|
|
def cog_check(self, ctx):
|
|
|
|
return not self.client.locked
|
|
|
|
|
|
|
|
@commands.command(name="Eten", aliases=["Food", "Menu"], usage="[Dag]*")
|
2021-02-08 18:25:25 +01:00
|
|
|
# @commands.check(checks.allowedChannels)
|
2020-10-13 21:02:40 +02:00
|
|
|
@help.Category(category=Category.School)
|
2021-09-26 13:10:57 +02:00
|
|
|
async def eten(self, ctx, day: str = None):
|
2021-10-04 20:15:01 +02:00
|
|
|
if day is not None:
|
|
|
|
day = day.lower()
|
|
|
|
|
2021-09-26 22:12:52 +02:00
|
|
|
embed = Menu(day).to_embed()
|
2021-09-26 13:10:57 +02:00
|
|
|
await ctx.reply(embed=embed, mention_author=False)
|
2020-10-13 21:02:40 +02:00
|
|
|
|
2021-09-20 01:42:13 +02:00
|
|
|
@commands.command(name="Les", aliases=["Class", "Classes", "Sched", "Schedule"], usage="[Dag]*")
|
2021-02-08 18:25:25 +01:00
|
|
|
# @commands.check(checks.allowedChannels)
|
2021-09-20 01:42:13 +02:00
|
|
|
@help.Category(category=Category.School)
|
2021-08-06 20:52:56 +02:00
|
|
|
async def les(self, ctx, day=None):
|
2021-10-04 20:15:01 +02:00
|
|
|
if day is not None:
|
|
|
|
day = day.lower()
|
|
|
|
|
2021-08-08 18:24:11 +02:00
|
|
|
date = les.find_target_date(day)
|
2021-08-08 18:33:32 +02:00
|
|
|
|
|
|
|
# Person explicitly requested a weekend-day
|
|
|
|
if day is not None and day.lower() in ("morgen", "overmorgen") and date.weekday() > 4:
|
|
|
|
return await ctx.send(f"{capitalize(day)} is het weekend.")
|
|
|
|
|
|
|
|
date = skip_weekends(date)
|
|
|
|
|
2021-08-08 18:12:16 +02:00
|
|
|
s = schedule.Schedule(date, int(config.get("year")), int(config.get("semester")), day is not None)
|
2021-08-08 19:32:41 +02:00
|
|
|
|
|
|
|
if s.semester_over:
|
|
|
|
return await ctx.send("Het semester is afgelopen.")
|
|
|
|
|
2021-09-26 21:27:52 +02:00
|
|
|
# DM only shows user's own minor
|
|
|
|
if ctx.guild is None:
|
|
|
|
minor_roles = [*schedule.find_minor(self.client, ctx.author.id)]
|
|
|
|
return await ctx.send(embed=s.create_schedule(minor_roles=minor_roles).to_embed())
|
|
|
|
|
2021-08-08 18:12:16 +02:00
|
|
|
return await ctx.send(embed=s.create_schedule().to_embed())
|
2020-10-13 21:02:40 +02:00
|
|
|
|
2021-02-08 18:46:15 +01:00
|
|
|
@commands.command(name="Pin", usage="[Message]")
|
2021-08-30 23:21:34 +02:00
|
|
|
@help.Category(category=Category.Other)
|
2021-02-08 18:46:15 +01:00
|
|
|
async def pin(self, ctx, message: discord.Message):
|
|
|
|
# In case people abuse, check if they're blacklisted
|
|
|
|
blacklist = []
|
|
|
|
|
|
|
|
if ctx.author.id in blacklist:
|
|
|
|
return
|
|
|
|
|
2021-06-02 15:52:53 +02:00
|
|
|
if message.is_system():
|
|
|
|
return await ctx.send("Dus jij wil system messages pinnen?\nMag niet.")
|
|
|
|
|
2021-02-08 18:46:15 +01:00
|
|
|
await message.pin(reason="Didier Pin door {}".format(ctx.author.display_name))
|
2021-06-02 15:52:53 +02:00
|
|
|
await ctx.message.add_reaction("✅")
|
2021-02-08 18:46:15 +01:00
|
|
|
|
2021-11-29 21:37:04 +01:00
|
|
|
@commands.command(name="Deadlines", aliases=["dl"])
|
|
|
|
@help.Category(category=Category.School)
|
|
|
|
async def deadlines(self, ctx):
|
|
|
|
await ctx.send(embed=Deadlines().to_embed())
|
|
|
|
|
2020-10-13 21:02:40 +02:00
|
|
|
|
|
|
|
def setup(client):
|
|
|
|
client.add_cog(School(client))
|