forked from blizzthewolf/SeaCogs
fix(moderation): fixing durations n such
This commit is contained in:
parent
d4095846ad
commit
7e6ad9f6e3
1 changed files with 10 additions and 5 deletions
|
@ -1782,19 +1782,22 @@ class Moderation(commands.Cog):
|
||||||
file = await self.ctx.message.attachments[0].read()
|
file = await self.ctx.message.attachments[0].read()
|
||||||
data = sorted(json.loads(file), key=lambda x: x['case'])
|
data = sorted(json.loads(file), key=lambda x: x['case'])
|
||||||
|
|
||||||
|
failed_cases = []
|
||||||
|
|
||||||
for case in data:
|
for case in data:
|
||||||
if case['type'] not in accepted_types:
|
if case['type'] not in accepted_types:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
timestamp = round(case['timestamp'] / 1000)
|
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))
|
duration = timedelta(seconds=round(float(case['duration']) / 1000))
|
||||||
except OverflowError:
|
else:
|
||||||
|
duration = 'NULL'
|
||||||
|
except OverflowError:
|
||||||
|
failed_cases.append(case['case'])
|
||||||
continue
|
continue
|
||||||
else:
|
|
||||||
duration = 'NULL'
|
|
||||||
|
|
||||||
if case['resolved']:
|
if case['resolved']:
|
||||||
resolved = 1
|
resolved = 1
|
||||||
|
@ -1852,6 +1855,8 @@ class Moderation(commands.Cog):
|
||||||
)
|
)
|
||||||
|
|
||||||
await interaction.edit_original_response(content="Import complete.")
|
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)
|
@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
|
async def import_button_n(self, interaction: discord.Interaction, button: discord.ui.Button): # pylint: disable=unused-argument
|
||||||
|
|
Loading…
Reference in a new issue