hotfix: release: 13.0.0-rc45

Fixed:
 - startBot shard data calculation
 - propper handling for websocket close code 1000

Changed:
 - shard shutdown code to 3000
This commit is contained in:
ITOH
2022-05-29 18:22:56 +02:00
parent 144e651259
commit c7eb3a9b0c
5 changed files with 10 additions and 9 deletions
+1 -1
View File
@@ -260,7 +260,7 @@ export function createEventHandlers(
} }
export async function startBot(bot: Bot) { export async function startBot(bot: Bot) {
if (!bot.botGatewayData) { if (!Object.keys(bot.botGatewayData ?? {}).length) {
bot.gateway.gatewayBot = await bot.helpers.getGatewayBot(); bot.gateway.gatewayBot = await bot.helpers.getGatewayBot();
bot.gateway.lastShardId = bot.gateway.gatewayBot.shards - 1; bot.gateway.lastShardId = bot.gateway.gatewayBot.shards - 1;
bot.gateway.manager.totalShards = bot.gateway.gatewayBot.shards; bot.gateway.manager.totalShards = bot.gateway.gatewayBot.shards;
+2 -3
View File
@@ -7,7 +7,6 @@ export async function handleClose(shard: Shard, close: CloseEvent): Promise<void
shard.stopHeartbeating(); shard.stopHeartbeating();
switch (close.code) { switch (close.code) {
// These events
case ShardSocketCloseCodes.TestingFinished: { case ShardSocketCloseCodes.TestingFinished: {
shard.state = ShardState.Offline; shard.state = ShardState.Offline;
shard.events.disconnected?.(shard); shard.events.disconnected?.(shard);
@@ -15,11 +14,11 @@ export async function handleClose(shard: Shard, close: CloseEvent): Promise<void
return; return;
} }
// On these codes a manual start will be done. // On these codes a manual start will be done.
case ShardSocketCloseCodes.Shutdown:
case ShardSocketCloseCodes.ReIdentifying: case ShardSocketCloseCodes.ReIdentifying:
case ShardSocketCloseCodes.Resharded: case ShardSocketCloseCodes.Resharded:
case ShardSocketCloseCodes.ResumeClosingOldConnection: case ShardSocketCloseCodes.ResumeClosingOldConnection:
case ShardSocketCloseCodes.ZombiedConnection: case ShardSocketCloseCodes.ZombiedConnection: {
case ShardSocketCloseCodes.Shutdown: {
shard.state = ShardState.Disconnected; shard.state = ShardState.Disconnected;
shard.events.disconnected?.(shard); shard.events.disconnected?.(shard);
+2 -4
View File
@@ -126,10 +126,8 @@ export interface ShardEvents {
} }
export enum ShardSocketCloseCodes { export enum ShardSocketCloseCodes {
/** A regular Shard shutdown. /** A regular Shard shutdown. */
* Discord will display this Shard as offline for other users. Shutdown = 3000,
*/
Shutdown = 1000,
/** A resume has been requested and therefore the old connection needs to be closed. */ /** A resume has been requested and therefore the old connection needs to be closed. */
ResumeClosingOldConnection = 3024, ResumeClosingOldConnection = 3024,
/** Did not receive a heartbeat ACK in time. /** Did not receive a heartbeat ACK in time.
+4
View File
@@ -915,6 +915,10 @@ export enum HTTPResponseCodes {
/** https://discord.com/developers/docs/topics/opcodes-and-status-codes#opcodes-and-status-codes */ /** https://discord.com/developers/docs/topics/opcodes-and-status-codes#opcodes-and-status-codes */
export enum GatewayCloseEventCodes { export enum GatewayCloseEventCodes {
/** A normal closure of the gateway.
* You may attempt to reconnect.
*/
NormalClosure = 1000,
/** We're not sure what went wrong. Try reconnecting? */ /** We're not sure what went wrong. Try reconnecting? */
UnknownError = 4000, UnknownError = 4000,
/** You sent an invalid [Gateway opcode](https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-opcodes) or an invalid payload for an opcode. Don't do that! */ /** You sent an invalid [Gateway opcode](https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-opcodes) or an invalid payload for an opcode. Don't do that! */
+1 -1
View File
@@ -25,7 +25,7 @@ export const GATEWAY_VERSION = 10;
// TODO: update this version // TODO: update this version
/** https://github.com/discordeno/discordeno/releases */ /** https://github.com/discordeno/discordeno/releases */
export const DISCORDENO_VERSION = "13.0.0-rc44"; export const DISCORDENO_VERSION = "13.0.0-rc45";
/** https://discord.com/developers/docs/reference#user-agent */ /** https://discord.com/developers/docs/reference#user-agent */
export const USER_AGENT = `DiscordBot (https://github.com/discordeno/discordeno, v${DISCORDENO_VERSION})`; export const USER_AGENT = `DiscordBot (https://github.com/discordeno/discordeno, v${DISCORDENO_VERSION})`;