fix(aurora): fixed a bunch of json issues

This commit is contained in:
Seaswimmer 2024-05-04 22:50:30 -04:00
parent e8d210df2a
commit 300d26dc7e
Signed by untrusted user: cswimr
GPG key ID: 5D671B5D03D65A7F
2 changed files with 6 additions and 6 deletions

View file

@ -98,8 +98,8 @@ class Moderation(AuroraGuildModel):
self.resolved_by,
self.resolve_reason,
self.expired,
dumps(self.changes).strip('"').replace('\\"', '"'),
dumps(self.metadata).strip('"').replace('\\"', '"'),
dumps(self.changes).replace('\\"', '"').replace('["{', '[{').replace('}"]', '}]'),
dumps(self.metadata).replace('\\"', '"').replace('["{', '[{').replace('}"]', '}]'),
self.moderation_id
))
cursor.close()
@ -119,8 +119,8 @@ class Moderation(AuroraGuildModel):
self.resolved_by,
self.resolve_reason,
self.expired,
dumps(self.changes).strip('"').replace('\\"', '"'),
dumps(self.metadata).strip('"').replace('\\"', '"'),
dumps(self.changes).replace('\\"', '"').replace('["{', '[{').replace('}"]', '}]'),
dumps(self.metadata).replace('\\"', '"').replace('["{', '[{').replace('}"]', '}]'),
)
@classmethod

View file

@ -134,7 +134,7 @@ def generate_dict(bot: Red, result: dict, guild_id: int) -> dict:
duration = None
if result[14] is not None:
changes = json.loads(result[14].strip('"').replace('\\"', '"'))
changes = json.loads(result[14].replace('\\"', '"').replace('["{', '[{').replace('}"]', '}]'))
change_obj_list = []
for change in changes:
change_obj_list.append(Change.from_dict(bot=bot, data=change))
@ -156,7 +156,7 @@ def generate_dict(bot: Red, result: dict, guild_id: int) -> dict:
"resolve_reason": result[12],
"expired": bool(result[13]),
"changes": change_obj_list if result[14] else [],
"metadata": json.loads(result[15].strip('"').replace('\\"', '"')) if result[15] else {},
"metadata": json.loads(result[15].replace('\\"', '"').replace('["{', '[{').replace('}"]', '}]')) if result[15] else {},
}
return case