diff --git a/moderation/moderation.py b/moderation/moderation.py index 8fe82b5..3e72219 100644 --- a/moderation/moderation.py +++ b/moderation/moderation.py @@ -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