fix(aurora): avoid keyerrors

This commit is contained in:
Seaswimmer 2024-05-24 04:15:27 -04:00
parent 9a4f19f4a1
commit 3dcc637920
Signed by untrusted user: cswimr
GPG key ID: 5D671B5D03D65A7F

View file

@ -187,16 +187,17 @@ async def case_factory(interaction: Interaction, moderation: Moderation) -> Embe
embed.description += f"\n**Role:** {role.name}" embed.description += f"\n**Role:** {role.name}"
if moderation.metadata: if moderation.metadata:
if moderation.metadata["imported_from"]: if moderation.metadata.get("imported_from"):
del moderation.metadata["imported_from"]
embed.description += ( embed.description += (
f"\n**Imported From:** {moderation.metadata['imported_from']}" f"\n**Imported From:** {moderation.metadata['imported_from']}"
) )
if moderation.metadata["imported_timestamp"]: moderation.metadata.pop("imported_from")
del moderation.metadata["imported_timestamp"] if moderation.metadata.get("imported_timestamp"):
embed.description += ( embed.description += (
f"\n**Imported Timestamp:** <t:{moderation.metadata['imported_timestamp']}> | <t:{moderation.metadata['imported_timestamp']}:R>" f"\n**Imported Timestamp:** <t:{moderation.metadata['imported_timestamp']}> | <t:{moderation.metadata['imported_timestamp']}:R>"
) )
moderation.metadata.pop("imported_timestamp")
if moderation.metadata.items():
for key, value in moderation.metadata.items(): for key, value in moderation.metadata.items():
embed.description += f"\n**{key.title()}:** {value}" embed.description += f"\n**{key.title()}:** {value}"