Files
discordeno/gateway/stopGateway.ts
T
Andreas Fink ad8a9920ac 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>
2022-02-28 13:41:15 -05:00

17 lines
434 B
TypeScript

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