forked from Bob-the-Bot1/Bob-the-Bot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwarningsget.py
24 lines (17 loc) · 867 Bytes
/
warningsget.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# this is settings.py
import sqlite3
conn = sqlite3.connect("warnings.db")
cursor = conn.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS warnings
(server_id INTEGER, user_id INTEGER, warn_code TEXT, moderator_id INTEGER, reason TEXT)''')
conn.commit()
def get_warnings(server_id: int, user_id: int) -> list:
# Retrieve all warnings for the specified user and server
cursor.execute("SELECT * FROM warnings WHERE server_id = ? AND user_id = ? ORDER BY rowid ASC",
(server_id, user_id))
return cursor.fetchall()
def get_warning_by_code(server_id: int, warn_code: str) -> tuple:
# Retrieve the warning with the specified warning code
cursor.execute("SELECT * FROM warnings WHERE server_id = ? AND warn_code = ?",
(server_id, warn_code))
return cursor.fetchone()