From d7a8fbe36721cb8362f856a554f1038ba5db3f2d Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Mon, 6 May 2024 16:02:00 -0400 Subject: [PATCH] fix(aurora): ignore moderations with the id 0 in the history command --- aurora/aurora.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index d764521..e071f15 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -20,7 +20,8 @@ from redbot.core import app_commands, commands, data_manager from redbot.core.app_commands import Choice from redbot.core.bot import Red from redbot.core.commands.converter import parse_relativedelta, parse_timedelta -from redbot.core.utils.chat_formatting import box, error, humanize_list, humanize_timedelta, warning +from redbot.core.utils.chat_formatting import (box, error, humanize_list, + humanize_timedelta, warning) from aurora.importers.aurora import ImportAuroraView from aurora.importers.galacticbot import ImportGalacticBotView @@ -30,11 +31,17 @@ from aurora.menus.immune import Immune from aurora.menus.overrides import Overrides from aurora.models import Change, Moderation from aurora.utilities.config import config, register_config -from aurora.utilities.database import connect, create_guild_table, fetch_case, mysql_log -from aurora.utilities.factory import addrole_embed, case_factory, changes_factory, evidenceformat_factory, guild_embed, immune_embed, message_factory, overrides_embed +from aurora.utilities.database import (connect, create_guild_table, fetch_case, + mysql_log) +from aurora.utilities.factory import (addrole_embed, case_factory, + changes_factory, evidenceformat_factory, + guild_embed, immune_embed, + message_factory, overrides_embed) from aurora.utilities.json import dump from aurora.utilities.logger import logger -from aurora.utilities.utils import check_moddable, check_permissions, get_footer_image, log, send_evidenceformat, timedelta_from_relativedelta +from aurora.utilities.utils import (check_moddable, check_permissions, + get_footer_image, log, send_evidenceformat, + timedelta_from_relativedelta) class Aurora(commands.Cog): @@ -1098,18 +1105,19 @@ class Aurora(commands.Cog): if target: query = f"""SELECT * FROM moderation_{interaction.guild.id} - WHERE target_id = ? + WHERE target_id = ? AND moderation_id != 0 ORDER BY moderation_id DESC;""" cursor.execute(query, (target.id,)) elif moderator: query = f"""SELECT * FROM moderation_{interaction.guild.id} - WHERE moderator_id = ? + WHERE moderator_id = ? AND moderation_id != 0 ORDER BY moderation_id DESC;""" cursor.execute(query, (moderator.id,)) else: query = f"""SELECT * FROM moderation_{interaction.guild.id} + WHERE moderation_id != 0 ORDER BY moderation_id DESC;""" cursor.execute(query) @@ -1117,10 +1125,9 @@ class Aurora(commands.Cog): moderation_list: List[Moderation] = [] for result in results: - if result["moderation_id"] != 0: - result.update({"guild_id": interaction.guild.id}) - moderation = Moderation.from_dict(interaction.client, dict(result)) - moderation_list.append(moderation) + result.update({"guild_id": interaction.guild.id}) + moderation = Moderation.from_dict(interaction.client, dict(result)) + moderation_list.append(moderation) case_quantity = len(moderation_list) page_quantity = ceil(case_quantity / pagesize)