From 09cb230d951a41205cc444b03fde34c830f1dba9 Mon Sep 17 00:00:00 2001 From: Luna Date: Thu, 2 Sep 2021 00:25:41 -0300 Subject: [PATCH] return user objects on dm.recipients but don't keep self user inside --- litecord/blueprints/dms.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/litecord/blueprints/dms.py b/litecord/blueprints/dms.py index 0e18e38..38d27e7 100644 --- a/litecord/blueprints/dms.py +++ b/litecord/blueprints/dms.py @@ -49,10 +49,11 @@ async def jsonify_dm(dm_id: int, user_id: int): dm_chan = await app.storage.get_dm(dm_id, user_id) if request.discord_api_version > 7: - new_recipients = [] - for recipient_user in dm_chan["recipients"]: - new_recipients.append(recipient_user["id"]) - dm_chan["recipients"] = new_recipients + self_user_index = index_by_func( + lambda user: user["id"] == str(user_id), dm_chan["recipients"] + ) + assert self_user_index is not None + dm_chan["recipients"].remove(self_user_index) return jsonify(dm_chan)