From 838600c3694820c6ba2c267fa7d7551fadc5eb3f Mon Sep 17 00:00:00 2001 From: Anorak_1 Date: Tue, 8 Aug 2023 17:33:37 +0200 Subject: [PATCH] Moved app message functions under MessageDB class for hinting --- dbutil.py | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/dbutil.py b/dbutil.py index 71f17f0..c054e83 100644 --- a/dbutil.py +++ b/dbutil.py @@ -2,22 +2,24 @@ import json import os import sqlite3 -def add_application_msg(msg_id: str, author_id: str, guild_id: str) -> None: - data = (msg_id, author_id, guild_id) - con = sqlite3.connect("applications.db") - cur = con.cursor() - cur.execute("INSERT INTO app_msg_db VALUES (?, ?, ?)", data) - con.commit() -def get_application_msg(msg_id: str): - con = sqlite3.connect("applications.db") - cur = con.cursor() - cur.execute(f"SELECT user_id, guild_id FROM app_msg_db WHERE msg_id={msg_id}") - user_id, guild_id = cur.fetchone() - return user_id, guild_id +class MessageDB(): + def add_application_msg(msg_id: str, author_id: str, guild_id: str) -> None: + data = (msg_id, author_id, guild_id) + con = sqlite3.connect("applications.db") + cur = con.cursor() + cur.execute("INSERT INTO app_msg_db VALUES (?, ?, ?)", data) + con.commit() -def remove_application_msg(msg_id: str) -> None: - con = sqlite3.connect("applications.db") - cur = con.cursor() - cur.execute(f"DELETE FROM app_msg_db WHERE msg_id={msg_id}") - con.commit() \ No newline at end of file + def get_application_msg(msg_id: str) -> tuple[str, str]: + con = sqlite3.connect("applications.db") + cur = con.cursor() + cur.execute(f"SELECT user_id, guild_id FROM app_msg_db WHERE msg_id={msg_id}") + user_id, guild_id = cur.fetchone() + return user_id, guild_id + + def remove_application_msg(msg_id: str) -> None: + con = sqlite3.connect("applications.db") + cur = con.cursor() + cur.execute(f"DELETE FROM app_msg_db WHERE msg_id={msg_id}") + con.commit() \ No newline at end of file