From b30e857f9f246e384b3a888d5d0119929d787a1c Mon Sep 17 00:00:00 2001 From: Yuki Joou Date: Sun, 26 Feb 2023 16:40:58 +0100 Subject: [PATCH] main: Added marriage checking command --- main.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/main.py b/main.py index 6ac0875..6a1e12c 100755 --- a/main.py +++ b/main.py @@ -39,6 +39,7 @@ Slash commands: ``` /help - Shows this message /marry - Marries someone +/marriage - Shows marriage information ``` """ @@ -60,6 +61,31 @@ def __find_mariage_for_member_id(member_id: int) -> list[int]: # Slash commands +@bot.slash_command() +@discord.guild_only() +@discord.option( + "target", type=discord.Member, + description="User whos marraige you want to check", + required=False, +) +async def marriage( + context: discord.ApplicationContext, target: discord.Member | None +): + who_to_check = target if target is not None else context.user + if who_to_check is None: + await context.respond("failed to get target!", ephemeral=True) + return + + marriage = __find_mariage_for_member_id(who_to_check.id) + if len(marriage) <= 0: + await context.respond(f"{who_to_check.mention} is not married yet :(") + return + + marriage_formatted = '💞'.join( + [f"<@{user}>" for user in marriage] + ) + await context.respond(marriage_formatted) + @bot.slash_command() @discord.guild_only()