From f98c48beed6a4bfd7f3ac9f7824399fc7b3d9948 Mon Sep 17 00:00:00 2001 From: ayntee Date: Thu, 25 Feb 2021 22:10:54 +0400 Subject: [PATCH 1/4] docs(LICENSE): capitalize "d" --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 880f17db9..d9af0aaea 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020-2021 discordeno +Copyright (c) 2020-2021 Discordeno Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From a6ba23553be1cf74869894b8337fc80d777be35b Mon Sep 17 00:00:00 2001 From: ayntee Date: Thu, 25 Feb 2021 22:12:22 +0400 Subject: [PATCH 2/4] feat(ws/shard): add closeWS() function (#543) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(ws/shard): add closeWS() function * foolproof reason lol * feat(ws/shard): handle 3069 close code * be less verbose 😂 --- src/ws/shard.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ws/shard.ts b/src/ws/shard.ts index 9f41b45bc..800348e40 100644 --- a/src/ws/shard.ts +++ b/src/ws/shard.ts @@ -163,6 +163,8 @@ export function createShard( data: { shardID: basicShard.id, code, reason, wasClean }, }); createShard(data, identifyPayload, false, shardID); + } else if (code === 3069 && reason === "[discordeno] requested closure") { + return; } else { basicShard.needToResume = true; await resumeConnection(botGatewayData, identifyPayload, shardID); @@ -407,5 +409,16 @@ export function sendWS(payload: DiscordPayload, shardID = 0) { const serialized = JSON.stringify(payload); shard.ws.send(serialized); + + return true; +} + +/** Closes the WebSocket connection or connection attempt */ +export function closeWS(shardID = 0) { + const shard = basicShards.get(shardID); + if (!shard) return false; + + shard.ws.close(3069, "[discordeno] requested closure"); + return true; } From ea42687623b87b2228cd7b425ba399703f06ebb2 Mon Sep 17 00:00:00 2001 From: ayntee Date: Thu, 25 Feb 2021 22:15:33 +0400 Subject: [PATCH 3/4] docs(LICENSE): remove license clause --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0bc857063..1759d3482 100644 --- a/README.md +++ b/README.md @@ -77,4 +77,4 @@ We appreciate your help! Before contributing, please read the ### License -[MIT © discordeno](https://github.com/discordeno/discordeno/blob/master/LICENSE) +[License can be found here](https://github.com/discordeno/discordeno/blob/master/LICENSE) From 369c3d0ce281125e16c732dc68001e2b0198ade5 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Thu, 25 Feb 2021 19:52:25 +0100 Subject: [PATCH 4/4] fix(rest): proxy 204 response remove from queue (#545) Co-authored-by: ayntee --- src/rest/queue.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rest/queue.ts b/src/rest/queue.ts index 5b1f51b55..1ef2fd766 100644 --- a/src/rest/queue.ts +++ b/src/rest/queue.ts @@ -93,6 +93,8 @@ export async function processQueue(id: string) { // SOMETIMES DISCORD RETURNS AN EMPTY 204 RESPONSE THAT CAN'T BE MADE TO JSON if (response.status === 204) { restCache.eventHandlers.fetchSuccess(queuedRequest.payload); + // REMOVE FROM QUEUE + queue.shift(); queuedRequest.request.respond({ status: 204 }); } else { // CONVERT THE RESPONSE TO JSON