WIP: Moderation type registry #26

Closed
cswimr wants to merge 146 commits from aurora-3rd-party into main
2 changed files with 6 additions and 6 deletions
Showing only changes of commit 300d26dc7e - Show all commits

View file

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

View file

@ -134,7 +134,7 @@ def generate_dict(bot: Red, result: dict, guild_id: int) -> dict:
duration = None duration = None
if result[14] is not 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 = [] change_obj_list = []
for change in changes: for change in changes:
change_obj_list.append(Change.from_dict(bot=bot, data=change)) 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], "resolve_reason": result[12],
"expired": bool(result[13]), "expired": bool(result[13]),
"changes": change_obj_list if result[14] else [], "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 return case