diff --git a/didier/cogs/fun.py b/didier/cogs/fun.py index e147f49..fed315f 100644 --- a/didier/cogs/fun.py +++ b/didier/cogs/fun.py @@ -136,7 +136,7 @@ class Fun(commands.Cog): @commands.hybrid_command(name="xkcd") @app_commands.rename(comic_id="id") async def xkcd(self, ctx: commands.Context, comic_id: Optional[int] = None): - """Fetch comic `#id` from xkcd + """Fetch comic `#id` from xkcd. If no argument to `id` is passed, this fetches today's comic instead. """ diff --git a/didier/cogs/school.py b/didier/cogs/school.py index 1c25283..d868439 100644 --- a/didier/cogs/school.py +++ b/didier/cogs/school.py @@ -116,10 +116,22 @@ class School(commands.Cog): mention_author=False, ) + @commands.hybrid_command(name="ufora") + async def ufora(self, ctx: commands.Context, course: str): + """Link the Ufora page for a course.""" + async with self.client.postgres_session as session: + ufora_course = await ufora_courses.get_course_by_name(session, course) + + if ufora_course is None: + return await ctx.reply(f"Found no course matching `{course}`", ephemeral=True) + + return await ctx.reply( + f"https://ufora.ugent.be/d2l/le/content/{ufora_course.course_id}/home", mention_author=False + ) + @study_guide.autocomplete("course") - async def _study_guide_course_autocomplete( - self, _: discord.Interaction, current: str - ) -> list[app_commands.Choice[str]]: + @ufora.autocomplete("course") + async def _course_autocomplete(self, _: discord.Interaction, current: str) -> list[app_commands.Choice[str]]: """Autocompletion for the 'course'-parameter""" return self.client.database_caches.ufora_courses.get_autocomplete_suggestions(current)