WIP: Refactor Aurora (3.0.0) #29
1 changed files with 5 additions and 27 deletions
|
@ -11,7 +11,6 @@ import sqlite3
|
|||
import time
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from math import ceil
|
||||
from typing import List
|
||||
|
||||
import discord
|
||||
from discord import Object
|
||||
|
@ -1114,35 +1113,14 @@ class Aurora(commands.Cog):
|
|||
database.close()
|
||||
return
|
||||
|
||||
cursor = database.cursor()
|
||||
|
||||
if target:
|
||||
query = f"""SELECT *
|
||||
FROM moderation_{interaction.guild.id}
|
||||
WHERE target_id = ? AND moderation_id != 0
|
||||
ORDER BY moderation_id DESC;"""
|
||||
cursor.execute(query, (target.id,))
|
||||
moderations = Moderation.find_by_target(interaction.client, interaction.guild.id, target.id)
|
||||
elif moderator:
|
||||
query = f"""SELECT *
|
||||
FROM moderation_{interaction.guild.id}
|
||||
WHERE moderator_id = ? AND moderation_id != 0
|
||||
ORDER BY moderation_id DESC;"""
|
||||
cursor.execute(query, (moderator.id,))
|
||||
moderations = Moderation.find_by_moderator(interaction.client, interaction.guild.id, moderator.id)
|
||||
else:
|
||||
query = f"""SELECT *
|
||||
FROM moderation_{interaction.guild.id}
|
||||
WHERE moderation_id != 0
|
||||
ORDER BY moderation_id DESC;"""
|
||||
cursor.execute(query)
|
||||
moderations = Moderation.get_all_cases(interaction.client, interaction.guild.id)
|
||||
|
||||
results = cursor.fetchall()
|
||||
moderation_list: List[Moderation] = []
|
||||
|
||||
for result in results:
|
||||
moderation = Moderation.from_result(interaction.client, result, interaction.guild.id)
|
||||
moderation_list.append(moderation)
|
||||
|
||||
case_quantity = len(moderation_list)
|
||||
case_quantity = len(moderations)
|
||||
page_quantity = ceil(case_quantity / pagesize)
|
||||
start_index = (page - 1) * pagesize
|
||||
end_index = page * pagesize
|
||||
|
@ -1155,7 +1133,7 @@ class Aurora(commands.Cog):
|
|||
|
||||
memory_dict = {}
|
||||
|
||||
for mod in moderation_list[start_index:end_index]:
|
||||
for mod in moderations[start_index:end_index]:
|
||||
if mod.target_id not in memory_dict:
|
||||
memory_dict.update({
|
||||
str(mod.target_id): await mod.get_target()
|
||||
|
|
Loading…
Reference in a new issue