11""""
2- Copyright © Krypton 2022 - https://github.com/kkrypt0nn (https://krypton.ninja)
2+ Copyright © Krypton 2019- 2022 - https://github.com/kkrypt0nn (https://krypton.ninja)
33Description:
4- This is a template to create your own discord bot in python .
4+ 🐍 A simple template to start to code your own and personalized discord bot in Python programming language .
55
6- Version: 5.4
6+ Version: 5.4.1
77"""
88
9+ import os
10+
911import aiosqlite
1012
13+ DATABASE_PATH = f"{ os .path .realpath (os .path .dirname (__file__ ))} /database/database.db"
14+
1115
1216async def is_blacklisted (user_id : int ) -> bool :
1317 """
@@ -16,7 +20,7 @@ async def is_blacklisted(user_id: int) -> bool:
1620 :param user_id: The ID of the user that should be checked.
1721 :return: True if the user is blacklisted, False if not.
1822 """
19- async with aiosqlite .connect ("database/database.db" ) as db :
23+ async with aiosqlite .connect (DATABASE_PATH ) as db :
2024 async with db .execute ("SELECT * FROM blacklist WHERE user_id=?" , (user_id ,)) as cursor :
2125 result = await cursor .fetchone ()
2226 return result is not None
@@ -28,7 +32,7 @@ async def add_user_to_blacklist(user_id: int) -> int:
2832
2933 :param user_id: The ID of the user that should be added into the blacklist.
3034 """
31- async with aiosqlite .connect ("database/database.db" ) as db :
35+ async with aiosqlite .connect (DATABASE_PATH ) as db :
3236 await db .execute ("INSERT INTO blacklist(user_id) VALUES (?)" , (user_id ,))
3337 await db .commit ()
3438 rows = await db .execute ("SELECT COUNT(*) FROM blacklist" )
@@ -43,7 +47,7 @@ async def remove_user_from_blacklist(user_id: int) -> int:
4347
4448 :param user_id: The ID of the user that should be removed from the blacklist.
4549 """
46- async with aiosqlite .connect ("database/database.db" ) as db :
50+ async with aiosqlite .connect (DATABASE_PATH ) as db :
4751 await db .execute ("DELETE FROM blacklist WHERE user_id=?" , (user_id ,))
4852 await db .commit ()
4953 rows = await db .execute ("SELECT COUNT(*) FROM blacklist" )
@@ -59,7 +63,7 @@ async def add_warn(user_id: int, server_id: int, moderator_id: int, reason: str)
5963 :param user_id: The ID of the user that should be warned.
6064 :param reason: The reason why the user should be warned.
6165 """
62- async with aiosqlite .connect ("database/database.db" ) as db :
66+ async with aiosqlite .connect (DATABASE_PATH ) as db :
6367 rows = await db .execute ("SELECT id FROM warns WHERE user_id=? AND server_id=? ORDER BY id DESC LIMIT 1" , (user_id , server_id ,))
6468 async with rows as cursor :
6569 result = await cursor .fetchone ()
@@ -77,7 +81,7 @@ async def remove_warn(warn_id: int, user_id: int, server_id: int) -> int:
7781 :param user_id: The ID of the user that was warned.
7882 :param server_id: The ID of the server where the user has been warned
7983 """
80- async with aiosqlite .connect ("database/database.db" ) as db :
84+ async with aiosqlite .connect (DATABASE_PATH ) as db :
8185 await db .execute ("DELETE FROM warns WHERE id=? AND user_id=? AND server_id=?" , (warn_id , user_id , server_id ,))
8286 await db .commit ()
8387 rows = await db .execute ("SELECT COUNT(*) FROM warns WHERE user_id=? AND server_id=?" , (user_id , server_id ,))
@@ -94,11 +98,11 @@ async def get_warnings(user_id: int, server_id: int) -> list:
9498 :param server_id: The ID of the server that should be checked.
9599 :return: A list of all the warnings of the user.
96100 """
97- async with aiosqlite .connect ("database/database.db" ) as db :
101+ async with aiosqlite .connect (DATABASE_PATH ) as db :
98102 rows = await db .execute ("SELECT user_id, server_id, moderator_id, reason, strftime('%s', created_at), id FROM warns WHERE user_id=? AND server_id=?" , (user_id , server_id ,))
99103 async with rows as cursor :
100104 result = await cursor .fetchall ()
101105 result_list = []
102106 for row in result :
103107 result_list .append (row )
104- return result_list
108+ return result_list
0 commit comments