diff --git a/bot.py b/bot.py index db5abed..f8b0b76 100644 --- a/bot.py +++ b/bot.py @@ -60,7 +60,13 @@ def remove_ping(term, user_id): elif user_id not in ping_terms[term]: return False else: - ping_terms[term].remove(user_id) + #if there is only one remaining person in the ping term list, delete the whole term + if len(ping_terms[term]) == 1 and ping_terms[term][0] == user_id: + del ping_terms[term] + #if there is more than on person in the ping term list, delete only that user_id + else: + ping_terms[term].remove(user_id) + config["ping_terms"] = ping_terms save_config("config.json", config) return True @@ -225,28 +231,28 @@ async def myLoop(): @bot.slash_command(description="Pings you when auction name contains the given term") async def ping_me(interaction: nextcord.Interaction, term: str): if add_ping(term, interaction.user.id): - await interaction.response.send_message(f"Success! You will be pinged for {term}", ephemeral=False) + await interaction.response.send_message(f"Success! You will be pinged for `{term}`", ephemeral=False) else: pings = get_user_pings(interaction.user.id) if len(pings) > 0: - await interaction.response.send_message(f"Failed to add {term}. You are pinged for {', '.join(pings)}", + await interaction.response.send_message(f"Failed to add `{term}`. You are pinged for `{', '.join(pings)}`", ephemeral=True) else: - await interaction.response.send_message(f"Failed to add {term}. You are not pinged for anything", + await interaction.response.send_message(f"Failed to add `{term}`. You are not pinged for anything", ephemeral=True) @bot.slash_command(description="No longer pings you when auction name contains the given term") async def unping_me(interaction: nextcord.Interaction, term: str): if remove_ping(term, interaction.user.id): - await interaction.response.send_message(f"Success! You will no longer be pinged for {term}", ephemeral=False) + await interaction.response.send_message(f"Success! You will no longer be pinged for `{term}`", ephemeral=False) else: pings = get_user_pings(interaction.user.id) if len(pings) > 0: - await interaction.response.send_message(f"Failed to remove {term}. You are pinged for {', '.join(pings)}", + await interaction.response.send_message(f"Failed to remove `{term}`. You are pinged for `{', '.join(pings)}`", ephemeral=True) else: - await interaction.response.send_message(f"Failed to remove {term}. You are not pinged for anything", + await interaction.response.send_message(f"Failed to remove `{term}`. You are not pinged for anything", ephemeral=True)