fix(gateway,bot): socket close debug handling & last/totalShards (#2261)

This commit is contained in:
ITOH
2022-05-29 17:39:27 +02:00
committed by GitHub
parent 23377aecab
commit d50be0834e
2 changed files with 3 additions and 5 deletions
+2
View File
@@ -262,6 +262,8 @@ export function createEventHandlers(
export async function startBot(bot: Bot) {
if (!bot.botGatewayData) {
bot.gateway.gatewayBot = await bot.helpers.getGatewayBot();
bot.gateway.lastShardId = bot.gateway.gatewayBot.shards - 1;
bot.gateway.manager.totalShards = bot.gateway.gatewayBot.shards;
}
bot.gateway.spawnShards();
+1 -5
View File
@@ -6,12 +6,8 @@ export async function handleClose(shard: Shard, close: CloseEvent): Promise<void
shard.stopHeartbeating();
console.log({ id: shard.id, close });
switch (close.code) {
case ShardSocketCloseCodes.Shutdown: {
throw new Error("SHUTDOWN");
}
// These events
case ShardSocketCloseCodes.TestingFinished: {
shard.state = ShardState.Offline;
shard.events.disconnected?.(shard);