feat: implement gateway queue (#844)

* feat: implement gateway queue

* process queues when adding to queue

* fix: tests fixed ready for review

* handle shard closed

Co-authored-by: Skillz4Killz <Skillz4Killz@users.noreply.github.com>
This commit is contained in:
Skillz4Killz
2021-04-13 12:29:35 -04:00
committed by GitHub
parent 16a5ac684a
commit 72618947f0
6 changed files with 90 additions and 37 deletions
+10 -10
View File
@@ -9,15 +9,15 @@ export function editBotStatus(data: Omit<StatusUpdate, "afk" | "since">) {
"loop",
`Running forEach loop in editBotStatus function.`,
);
shard.ws.send(
JSON.stringify({
op: DiscordGatewayOpcodes.StatusUpdate,
d: {
since: null,
afk: false,
...data,
},
}),
);
shard.queue.push({
op: DiscordGatewayOpcodes.StatusUpdate,
d: {
since: null,
afk: false,
...data,
},
});
ws.processQueue(shard.id);
});
}