From 18bb70156d2586b08105eccf45ddb5ec29704359 Mon Sep 17 00:00:00 2001 From: Yuki Joou Date: Sun, 26 Feb 2023 17:03:31 +0100 Subject: [PATCH] main: Added divorce command because its better to be good friends than angry lovers :3 --- main.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/main.py b/main.py index 273d2b3..f2ebb9b 100755 --- a/main.py +++ b/main.py @@ -61,6 +61,38 @@ def __find_mariage_for_member_id(member_id: int) -> list[int]: # Slash commands +@bot.slash_command() +@discord.guild_only() +async def divorce(context: discord.ApplicationContext): + if context.user is None: + await context.respond("error uwu", ephemeral=True) + return + + user_marriage = __find_mariage_for_member_id(context.user.id) + if len(user_marriage) <= 0: + await context.respond("you can't divorce if you're not married, silly :3") + return + + data = data_manager.get_data() + if len(user_marriage) <= 2: + data["marriages"].remove(user_marriage) + with data_manager.DataWriter() as writer: + writer.set_data(data) + await context.respond(f"things didn't work out, and {context.user.mention} choose to divorce") + return + + # Is polycule + new_polycule = user_marriage.copy() + new_polycule.remove(context.user.id) + data["marriages"].remove(user_marriage) + data["marriages"].append(new_polycule) + + with data_manager.DataWriter() as writer: + writer.set_data(data) + + await context.respond(f"{context.user.mention} has taken the decision to step away from the polycule") + + @bot.slash_command() @discord.guild_only() @discord.option(