WIP: Refactor Aurora (3.0.0) #29
1 changed files with 7 additions and 7 deletions
|
@ -2,7 +2,7 @@ import json
|
|||
import sqlite3
|
||||
from datetime import datetime, timedelta
|
||||
from time import time
|
||||
from typing import Dict, Iterable, List, Optional, Union
|
||||
from typing import Dict, Iterable, List, Optional, Tuple, Union
|
||||
|
||||
import discord
|
||||
from discord import NotFound
|
||||
|
@ -202,7 +202,7 @@ class Moderation(AuroraGuildModel):
|
|||
return cls.from_dict(bot=bot, data=case)
|
||||
|
||||
@classmethod
|
||||
def execute(cls, bot: Red, guild_id: int, query: str, parameters: tuple | None = None) -> List["Moderation"]:
|
||||
def execute(cls, bot: Red, guild_id: int, query: str, parameters: tuple | None = None) -> Tuple["Moderation"]:
|
||||
from ..utilities.database import connect
|
||||
if not parameters:
|
||||
parameters = ()
|
||||
|
@ -218,8 +218,8 @@ class Moderation(AuroraGuildModel):
|
|||
case = cls.from_result(bot=bot, result=result, guild_id=guild_id)
|
||||
if case.moderation_id != 0:
|
||||
cases.append(case)
|
||||
return cases
|
||||
return []
|
||||
return tuple(iterable=cases)
|
||||
return ()
|
||||
|
||||
@classmethod
|
||||
def from_sql(cls, bot: Red, moderation_id: int, guild_id: int) -> "Moderation":
|
||||
|
@ -234,7 +234,7 @@ class Moderation(AuroraGuildModel):
|
|||
raise ValueError(f"Case {moderation_id} not found in moderation_{guild_id}!")
|
||||
|
||||
@classmethod
|
||||
def find_by_target(cls, bot: Red, guild_id: int, target: int, types: list | None = None) -> List["Moderation"]:
|
||||
def find_by_target(cls, bot: Red, guild_id: int, target: int, types: list | None = None) -> Tuple["Moderation"]:
|
||||
query = f"SELECT * FROM moderation_{guild_id} WHERE target_id = ?"
|
||||
if types:
|
||||
query += f" AND moderation_type IN ({', '.join(['?' for _ in types])})"
|
||||
|
@ -243,7 +243,7 @@ class Moderation(AuroraGuildModel):
|
|||
return cls.execute(bot=bot, guild_id=guild_id, query=query, parameters=(target, *types) if types else (target,))
|
||||
|
||||
@classmethod
|
||||
def find_by_moderator(cls, bot: Red, guild_id: int, moderator: int, types: list | None = None) -> List["Moderation"]:
|
||||
def find_by_moderator(cls, bot: Red, guild_id: int, moderator: int, types: list | None = None) -> Tuple["Moderation"]:
|
||||
query = f"SELECT * FROM moderation_{guild_id} WHERE moderator_id = ?"
|
||||
if types:
|
||||
query += f" AND moderation_type IN ({', '.join(['?' for _ in types])})"
|
||||
|
@ -252,7 +252,7 @@ class Moderation(AuroraGuildModel):
|
|||
return cls.execute(bot=bot, guild_id=guild_id, query=query, parameters=(moderator, *types) if types else (moderator,))
|
||||
|
||||
@classmethod
|
||||
def get_all_cases(cls, bot: Red, guild_id: int, types: list | None = None) -> List["Moderation"]:
|
||||
def get_all_cases(cls, bot: Red, guild_id: int, types: list | None = None) -> Tuple["Moderation"]:
|
||||
query = f"SELECT * FROM moderation_{guild_id}"
|
||||
if types:
|
||||
query += f" WHERE moderation_type IN ({', '.join(['?' for _ in types])})"
|
||||
|
|
Loading…
Reference in a new issue