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 (
# Create the birthdays table if it doesn't exist
cursor.execute("""
CREATE TABLE IF NOT EXISTS birthdays (
user_id INTEGER, user_id INTEGER,
guild_id INTEGER, guild_id INTEGER,
user_name TEXT, user_name TEXT,
birthday TEXT, birthday TEXT,
PRIMARY KEY (user_id, guild_id) PRIMARY KEY (user_id, guild_id)
);""") );
""")
# 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.commit()
conn.close() conn.close()
self.logger.info("Database and table created successfully.")
else:
self.logger.info("Database already exists.")
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):