fix(moderation): fixed trying to import the 0th case

This commit is contained in:
Seaswimmer 2023-12-18 16:33:09 -05:00
parent f8b1e03d0e
commit 56d316b6fa
Signed by untrusted user: cswimr
GPG key ID: 1EBC234EEDA901AE

View file

@ -31,7 +31,7 @@ class ImportModerationView(ui.View):
await interaction.edit_original_response(content="Importing moderations...") await interaction.edit_original_response(content="Importing moderations...")
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['moderation_id']) data: [dict] = sorted(json.loads(file), key=lambda x: x['moderation_id'])
user_mod_types = [ user_mod_types = [
'NOTE', 'NOTE',
@ -51,6 +51,9 @@ class ImportModerationView(ui.View):
failed_cases = [] failed_cases = []
for case in data: for case in data:
if case['moderation_id'] == 0:
continue
if 'target_type' not in case or not case['target_type']: if 'target_type' not in case or not case['target_type']:
if case['moderation_type'] in user_mod_types: if case['moderation_type'] in user_mod_types:
case['target_type'] = 'USER' case['target_type'] = 'USER'