Archived
generated from imcompiling/discord-bot-template
Add birthday clear command. (not removing from database right now).
build_develop / build (push) Failing after 18s
build_develop / build (push) Failing after 18s
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user