From 75c3f98c989aee5ede03f1974f6ef6429818aa67 Mon Sep 17 00:00:00 2001 From: Anorak_1 Date: Sat, 12 Aug 2023 13:28:28 +0200 Subject: [PATCH] added StartButtonDB because discord custom id suck --- dbutil.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/dbutil.py b/dbutil.py index b6ae37d..7d4445c 100644 --- a/dbutil.py +++ b/dbutil.py @@ -25,6 +25,29 @@ class MessageDB(): cur.execute(f"DELETE FROM app_msg_db WHERE msg_id={msg_id}") con.commit() + +class StartButtonDB(): + def add_start_msg(msg_id: str, app_name: str, guild_id: str) -> None: + data = (msg_id, app_name, guild_id) + con = sqlite3.connect("applications.db") + cur = con.cursor() + cur.execute("INSERT INTO app_start_db VALUES (?, ?, ?)", data) + con.commit() + + def get_start_msg(msg_id: str) -> tuple[str, str]: + con = sqlite3.connect("applications.db") + cur = con.cursor() + cur.execute("SELECT app_name, guild_id FROM app_start_db WHERE msg_id=?", (str(msg_id), )) + #print(cur.fetchone()) + app_name, guild_id = cur.fetchone() + return app_name, guild_id + + def remove_start_msg(msg_id: str) -> None: + con = sqlite3.connect("applications.db") + cur = con.cursor() + cur.execute(f"DELETE FROM app_start_db WHERE msg_id={msg_id}") + con.commit() + class GuildAppDB(): def create_guild(guild_id: str, guild_name: str) -> None: applications = {}