From 026f6f3a2117f9f7f2bc94e5639ca50a5b728a41 Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 13 Aug 2024 23:48:02 -0400 Subject: [PATCH] FIX: Somehow SetBirthday Got deleted --- user/birthday.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/user/birthday.py b/user/birthday.py index 9fc37f4..0e102a9 100644 --- a/user/birthday.py +++ b/user/birthday.py @@ -81,6 +81,22 @@ class Birthday: async def delete_birthday(self, user_id, guild_id): self.data_access_manager.delete_data(user_id, guild_id) + async def set_birthday(self, interaction: discord.Interaction, user_id: int, guild_id: int, birthday_str: str): + if not self.consent_manager.has_consent(user_id, guild_id): + await self.consent_manager.request_consent(interaction) + return # Exit early since consent hasn't been given yet + + conn = sqlite3.connect(self.db_path) + cursor = conn.cursor() + cursor.execute("""INSERT INTO birthdays (user_id, guild_id, birthday) + VALUES (?, ?, ?) ON CONFLICT(user_id, guild_id) + DO UPDATE SET birthday = excluded.birthday;""", + (user_id, guild_id, birthday_str)) + conn.commit() + conn.close() + self.logger.info(f"{user_id}'s birthday has been set to {birthday_str}.") + await interaction.response.send_message(f"Your birthday has been set to {birthday_str}.", ephemeral=True) + async def get_birthday(self, user_id, guild_id): conn = sqlite3.connect(self.db_path) cursor = conn.cursor()