fix(moderation): fixing durations n such

This commit is contained in:
Seaswimmer 2023-12-16 20:43:01 -05:00
parent d4095846ad
commit 7e6ad9f6e3
Signed by untrusted user: cswimr
GPG key ID: 1EBC234EEDA901AE

View file

@ -1782,19 +1782,22 @@ class Moderation(commands.Cog):
file = await self.ctx.message.attachments[0].read()
data = sorted(json.loads(file), key=lambda x: x['case'])
failed_cases = []
for case in data:
if case['type'] not in accepted_types:
continue
timestamp = round(case['timestamp'] / 1000)
if case['duration'] is not None:
try:
try:
if case['duration'] is not None and float(case['duration']) != 0:
duration = timedelta(seconds=round(float(case['duration']) / 1000))
except OverflowError:
else:
duration = 'NULL'
except OverflowError:
failed_cases.append(case['case'])
continue
else:
duration = 'NULL'
if case['resolved']:
resolved = 1
@ -1852,6 +1855,8 @@ class Moderation(commands.Cog):
)
await interaction.edit_original_response(content="Import complete.")
if failed_cases:
await interaction.edit_original_response(content="Import complete.\n*Failed to import the following cases:*\n```{failed_cases}```")
@discord.ui.button(label="No", style=discord.ButtonStyle.danger)
async def import_button_n(self, interaction: discord.Interaction, button: discord.ui.Button): # pylint: disable=unused-argument