main: Added divorce command
because its better to be good friends than angry lovers :3
This commit is contained in:
parent
44d881dfa3
commit
18bb70156d
1 changed files with 32 additions and 0 deletions
32
main.py
32
main.py
|
@ -61,6 +61,38 @@ def __find_mariage_for_member_id(member_id: int) -> list[int]:
|
||||||
|
|
||||||
# Slash commands
|
# 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()
|
@bot.slash_command()
|
||||||
@discord.guild_only()
|
@discord.guild_only()
|
||||||
@discord.option(
|
@discord.option(
|
||||||
|
|
Loading…
Reference in a new issue