From a6dbe163dd3df12ad98465b1dfc040b8eff8805e Mon Sep 17 00:00:00 2001 From: RedGuy12 <61329810+RedGuy12@users.noreply.github.com> Date: Wed, 14 Jun 2023 13:07:48 -0500 Subject: [PATCH] fix(ThreadManager): Fix internal crash upon conditionally resolving thread members (#9648) * fix(ThreadManager): Fix crash * chore: prettier --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- packages/discord.js/src/managers/ThreadManager.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/discord.js/src/managers/ThreadManager.js b/packages/discord.js/src/managers/ThreadManager.js index 900d811996a1..005e02c45392 100644 --- a/packages/discord.js/src/managers/ThreadManager.js +++ b/packages/discord.js/src/managers/ThreadManager.js @@ -188,10 +188,10 @@ class ThreadManager extends CachedManager { }, new Collection()); // Discord sends the thread id as id in this object - const threadMembers = rawThreads.members.reduce( - (coll, raw) => coll.set(raw.user_id, threads.get(raw.id).members._add(raw)), - new Collection(), - ); + const threadMembers = rawThreads.members.reduce((coll, raw) => { + const thread = threads.get(raw.id); + return thread ? coll.set(raw.user_id, thread.members._add(raw)) : coll; + }, new Collection()); const response = { threads, members: threadMembers };