From 8ecf8f3ed3d9018795f680303478b1e4f183e2ae Mon Sep 17 00:00:00 2001 From: ajax146 <31014239+ajax146@users.noreply.github.com> Date: Wed, 15 Oct 2025 16:28:29 -0400 Subject: [PATCH] Fixes multiple bugs in the modlog highscore feature --- techsupport_bot/commands/modlog.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/techsupport_bot/commands/modlog.py b/techsupport_bot/commands/modlog.py index fa55633e..47560506 100644 --- a/techsupport_bot/commands/modlog.py +++ b/techsupport_bot/commands/modlog.py @@ -57,6 +57,7 @@ async def high_score_command(self: Self, interaction: discord.Interaction) -> No Args: interaction (discord.Interaction): The interaction that started this command """ + await interaction.response.defer() all_bans = await self.bot.models.BanLog.query.where( self.bot.models.BanLog.guild_id == str(interaction.guild.id) ).gino.all() @@ -68,19 +69,22 @@ async def high_score_command(self: Self, interaction: discord.Interaction) -> No embed = discord.Embed(title="Most active moderators") final_string = "" - for index, (moderator_id, count) in enumerate(sorted_ban_frequency): - moderator = await interaction.guild.fetch_member(int(moderator_id)) + for index, (moderator_id, count) in enumerate(sorted_ban_frequency[:10]): + try: + moderator = await interaction.guild.fetch_member(int(moderator_id)) + except discord.NotFound: + moderator = None if moderator: final_string += ( f"{index+1}. {moderator.display_name} " - f"{moderator.mention} ({moderator.id}) - ({count})\n" + f"{moderator.mention} ({moderator.id}) - {count}\n" ) else: - final_string += {f"{index+1}. Moderator left: {moderator_id}"} + final_string += f"{index+1}. Moderator left: {moderator_id} - {count}\n" embed.description = final_string embed.color = discord.Color.blue() - await interaction.response.send_message(embed=embed) + await interaction.followup.send(embed=embed) @modlog_group.command( name="lookup-user",