Merge branch 'master' of https://github.com/discordeno/discordeno into proxy-ws

This commit is contained in:
Skillz
2021-02-25 17:12:34 -05:00
4 changed files with 17 additions and 2 deletions
+2
View File
@@ -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
+13
View File
@@ -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;
}