feat(gateway): add stopGateway function (#2078)

* Move the shard stopping to gatewayManager in order to stop the gateway standalone.

* Update gateway/gateway_manager.ts

Co-authored-by: ITOH <to@itoh.at>

* Update gateway/stopGateway.ts

Co-authored-by: ITOH <to@itoh.at>

* Update gateway/stopGateway.ts

* Update gateway/stopGateway.ts

* Update gateway/stopGateway.ts

Co-authored-by: ITOH <to@itoh.at>
Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
This commit is contained in:
Andreas Fink
2022-02-28 19:41:15 +01:00
committed by GitHub
parent 4aac2246ad
commit ad8a9920ac
3 changed files with 21 additions and 11 deletions
+16
View File
@@ -0,0 +1,16 @@
/** Use this function to stop the gateway properly */
export async function stopGateway(gateway: GatewayManager, code = 3061, reason = "Discordeno Testing Finished! Do Not RESUME!") {
// STOP WS
gateway.shards.forEach((shard) => {
clearInterval(shard.heartbeat.intervalId);
gateway.closeWS(
shard.ws,
code,
reason,
);
});
await delay(5000);
}