WIP: Moderation type registry #26
1 changed files with 19 additions and 12 deletions
|
@ -202,15 +202,22 @@ class Moderation(AuroraGuildModel):
|
||||||
return cls.from_dict(bot=bot, data=case)
|
return cls.from_dict(bot=bot, data=case)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def execute(cls, bot: Red, guild_id: int, query: str, parameters: tuple | None = None) -> Tuple["Moderation"]:
|
def execute(cls, bot: Red, guild_id: int, query: str, parameters: tuple | None = None, cursor: Cursor | None = None) -> Tuple["Moderation"]:
|
||||||
from ..utilities.database import connect
|
from ..utilities.database import connect
|
||||||
if not parameters:
|
if not parameters:
|
||||||
parameters = ()
|
parameters = ()
|
||||||
with connect() as database:
|
if not cursor:
|
||||||
|
no_cursor = True
|
||||||
|
database = connect()
|
||||||
cursor = database.cursor()
|
cursor = database.cursor()
|
||||||
|
else:
|
||||||
|
no_cursor = False
|
||||||
|
|
||||||
cursor.execute(query, parameters)
|
cursor.execute(query, parameters)
|
||||||
results = cursor.fetchall()
|
results = cursor.fetchall()
|
||||||
|
if no_cursor:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
database.close()
|
||||||
|
|
||||||
if results:
|
if results:
|
||||||
cases = []
|
cases = []
|
||||||
|
|
Loading…
Reference in a new issue