FIX: FIxed a issue with the consent

This commit is contained in:
Dan 2024-08-12 19:01:26 -04:00
parent deb1143990
commit b2d607cc07

View File

@ -19,23 +19,31 @@ class Birthday:
self.ensure_db() self.ensure_db()
def ensure_db(self): def ensure_db(self):
# Ensure the directory exists
os.makedirs(os.path.dirname(self.db_path), exist_ok=True) os.makedirs(os.path.dirname(self.db_path), exist_ok=True)
if not os.path.exists(self.db_path):
self.logger.info("Database does not exist. Creating a new database.") # Connect to the database
conn = sqlite3.connect(self.db_path) conn = sqlite3.connect(self.db_path)
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute("""CREATE TABLE IF NOT EXISTS birthdays (
user_id INTEGER, # Create the birthdays table if it doesn't exist
guild_id INTEGER, cursor.execute("""
user_name TEXT, CREATE TABLE IF NOT EXISTS birthdays (
birthday TEXT, user_id INTEGER,
PRIMARY KEY (user_id, guild_id) guild_id INTEGER,
);""") user_name TEXT,
conn.commit() birthday TEXT,
conn.close() PRIMARY KEY (user_id, guild_id)
self.logger.info("Database and table created successfully.") );
else: """)
self.logger.info("Database already exists.")
# You can log or print to ensure this step was reached
self.logger.info("Birthday table ensured")
# Commit the changes and close the connection
conn.commit()
conn.close()
async def set_birthday(self, interaction: discord.Interaction, user_id, guild_id, birthday): async def set_birthday(self, interaction: discord.Interaction, user_id, guild_id, birthday):
if not self.consent_manager.has_consent(user_id, guild_id): if not self.consent_manager.has_consent(user_id, guild_id):