diff --git a/cogs/commands/birthday.py b/cogs/commands/birthday.py index d31ccef..0ad3204 100644 --- a/cogs/commands/birthday.py +++ b/cogs/commands/birthday.py @@ -15,7 +15,7 @@ from main import birthday_list class BirthdayCog(commands.Cog, name="Birthday Commands"): """Class holds birthday commands.""" - @nextcord.slash_command() + @nextcord.slash_command(guild_ids=[1000247361639030804, 822199658306076672]) async def birthday(self, interaction: nextcord.Interaction) -> None: """Parent slash command for birthday. Never called.""" @@ -65,3 +65,26 @@ class BirthdayCog(commands.Cog, name="Birthday Commands"): session.commit() await interaction.followup.send(f"Birthday set to {month}/{day}.", ephemeral=True) + + @birthday.subcommand(description="Remove yourself from the birthday list.") + async def clear(self, interaction: nextcord.Interaction) -> None: + """ + Remove the user from the birthday database. + + Args: + interaction (nextcord.Interaction): Interaction that invoked the command. + + """ + # Ensure that a person used the command. + if interaction.user is None: + return + + if interaction.user.id in birthday_list: + birthday_list.remove(interaction.user.id) + + with Session(engine) as session: + stmt = select(UserBirthday).where(UserBirthday.user_id == interaction.user.id) + session.delete(stmt) + session.commit() + + await interaction.followup.send("Birthday cleared.", ephemeral=True)