fix(aurora): fixed Moderation.get_latest() breaking when using only before and after, and no other kwargs
This commit is contained in:
parent
14750787b2
commit
f3246366ff
2 changed files with 10 additions and 4 deletions
|
@ -44,7 +44,7 @@ class Aurora(commands.Cog):
|
|||
This cog stores all of its data in an SQLite database."""
|
||||
|
||||
__author__ = ["SeaswimmerTheFsh"]
|
||||
__version__ = "2.4.0"
|
||||
__version__ = "2.4.1"
|
||||
__documentation__ = "https://seacogs.coastalcommits.com/aurora/"
|
||||
|
||||
async def red_delete_data_for_user(self, *, requester, user_id: int):
|
||||
|
|
|
@ -315,16 +315,22 @@ class Moderation(AuroraGuildModel):
|
|||
async def get_latest(cls, bot: Red, guild_id: int, before: datetime = None, after: datetime = None, limit: int | None = None, offset: int = 0, types: Iterable[Type] | None = None, cursor: Cursor | None = None) -> Tuple["Moderation"]:
|
||||
params = []
|
||||
query = f"SELECT * FROM moderation_{guild_id} ORDER BY moderation_id DESC"
|
||||
conditions = []
|
||||
|
||||
if types:
|
||||
query += f" WHERE moderation_type IN ({', '.join(['?' for _ in types])})"
|
||||
conditions.append(f"moderation_type IN ({', '.join(['?' for _ in types])})")
|
||||
for t in types:
|
||||
params.append(t.key)
|
||||
if before:
|
||||
query += " WHERE timestamp < ?"
|
||||
conditions.append("timestamp < ?")
|
||||
params.append(int(before.timestamp()))
|
||||
if after:
|
||||
query += " WHERE timestamp > ?"
|
||||
conditions.append("timestamp > ?")
|
||||
params.append(int(after.timestamp()))
|
||||
|
||||
if conditions:
|
||||
query += " WHERE " + " AND ".join(conditions)
|
||||
|
||||
if limit:
|
||||
query += " LIMIT ? OFFSET ?"
|
||||
params.extend((limit, offset))
|
||||
|
|
Loading…
Reference in a new issue