fix(moderation): added caching for history command
Some checks failed
Pylint / Pylint (3.10) (push) Failing after 56s

This commit is contained in:
Seaswimmer 2023-12-14 14:41:38 -05:00
parent 5babdb74c2
commit 9cd63ce92b
Signed by: cswimr
GPG key ID: 1EBC234EEDA901AE

View file

@ -780,9 +780,14 @@ class Moderation(commands.Cog):
embed = discord.Embed(color=await self.bot.get_embed_color(None))
embed.set_author(icon_url=interaction.guild.icon.url, name='Infraction History')
embed.set_footer(text=f"Page {page}/{page_quantity} | {case_quantity} Results")
memory_dict = {}
for case in result_dict_list[start_index:end_index]:
target_user = await self.fetch_user_dict(interaction, case['target_id'])
moderator_user = await self.fetch_user_dict(interaction, case['moderator_id'])
if case['target_id'] not in memory_dict:
memory_dict[str(case['target_id'])] = await self.fetch_user_dict(interaction, case['target_id'])
target_user = memory_dict[str(case['target_id'])]
if case['moderator_id'] not in memory_dict:
memory_dict[str(case['moderator_id'])] = await self.fetch_user_dict(interaction, case['moderator_id'])
moderator_user = memory_dict[str(case['moderator_id'])]
target_name = target_user['name'] if target_user['discriminator'] == "0" else f"{target_user['name']}#{target_user['discriminator']}"
moderator_name = moderator_user['name'] if moderator_user['discriminator'] == "0" else f"{moderator_user['name']}#{moderator_user['discriminator']}"
field_name = f"Case #{case['moderation_id']} ({str.title(case['moderation_type'])})"