Skip to content

Commit d4b6a16

Browse files
committed
Author JSON
1 parent bb4d05c commit d4b6a16

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/daf/logging/_logging.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,19 @@ async def _save_log(self, guild_context: dict, message_context: dict, author_con
263263
json_data["name"] = guild_context["name"]
264264
json_data["id"] = guild_context["id"]
265265
json_data["type"] = guild_context["type"]
266-
json_data["author"] = author_context
267-
json_data["message_history"] = []
266+
json_data["authors"] = {}
268267

269-
json_data["message_history"].insert(0,
268+
author_id_str = str(author_context["id"])
269+
if author_id_str not in json_data["authors"]:
270+
messages = author_context["messages"] = []
271+
json_data["authors"][author_id_str] = author_context
272+
else:
273+
messages = json_data["authors"][author_id_str]["messages"]
274+
275+
messages.insert(0,
270276
{
271277
**message_context,
272-
"index": json_data["message_history"][0]["index"] + 1 if len(json_data["message_history"]) else 0,
278+
"index": messages[0]["index"] + 1 if len(messages) else 0,
273279
"timestamp": timestamp
274280
}
275281
)

0 commit comments

Comments
 (0)