Skip to content

Commit

Permalink
FIX: FIxed a issue with the consent
Browse files Browse the repository at this point in the history
  • Loading branch information
advtech92 committed Aug 12, 2024
1 parent deb1143 commit b2d607c
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions user/birthday.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,31 @@ def __init__(self, client):
self.ensure_db()

def ensure_db(self):
# Ensure the directory exists
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.")
conn = sqlite3.connect(self.db_path)
cursor = conn.cursor()
cursor.execute("""CREATE TABLE IF NOT EXISTS birthdays (
user_id INTEGER,
guild_id INTEGER,
user_name TEXT,
birthday TEXT,
PRIMARY KEY (user_id, guild_id)
);""")
conn.commit()
conn.close()
self.logger.info("Database and table created successfully.")
else:
self.logger.info("Database already exists.")

# Connect to the database
conn = sqlite3.connect(self.db_path)
cursor = conn.cursor()

# Create the birthdays table if it doesn't exist
cursor.execute("""
CREATE TABLE IF NOT EXISTS birthdays (
user_id INTEGER,
guild_id INTEGER,
user_name TEXT,
birthday TEXT,
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.close()


async def set_birthday(self, interaction: discord.Interaction, user_id, guild_id, birthday):
if not self.consent_manager.has_consent(user_id, guild_id):
Expand Down

0 comments on commit b2d607c

Please sign in to comment.