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 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) 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 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; }