summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gateway/events/Close.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/gateway/events/Close.ts b/src/gateway/events/Close.ts
index 572037af..16f6b188 100644
--- a/src/gateway/events/Close.ts
+++ b/src/gateway/events/Close.ts
@@ -54,11 +54,19 @@ export async function Close(this: WebSocket, code: number, reason: Buffer) {
 			status: "offline",
 		};
 
+		// TODO
+		// If a user was deleted, they may still be connected to gateway,
+		// which will cause this to throw when they disconnect.
+		// just send the ID of the user instead of the full correct payload for now
+		const userOrId = await User.getPublicUser(this.user_id).catch(() => ({
+			id: this.user_id,
+		}));
+
 		await emitEvent({
 			event: "PRESENCE_UPDATE",
 			user_id: this.user_id,
 			data: {
-				user: await User.getPublicUser(this.user_id),
+				user: userOrId,
 				activities: session.activities,
 				client_status: session?.client_info,
 				status: session.status,