fix(WebSocketManager): always cache result of fetchGatewayInformation (#9611)

* fix(WebSocketManager): always cache result of fetchGatewayInformation

* fix: add comment
This commit is contained in:
Qjuh
2023-05-29 20:45:17 +02:00
committed by GitHub
parent 24a61495b9
commit df8b6e9934

View File

@@ -234,7 +234,8 @@ export class WebSocketManager extends AsyncEventEmitter<ManagerShardEventsMap> {
const data = (await this.options.rest.get(Routes.gatewayBot())) as RESTGetAPIGatewayBotResult;
this.gatewayInformation = { data, expiresAt: Date.now() + data.session_start_limit.reset_after };
// For single sharded bots session_start_limit.reset_after will be 0, use 5 seconds as a minimum expiration time
this.gatewayInformation = { data, expiresAt: Date.now() + (data.session_start_limit.reset_after || 5_000) };
return this.gatewayInformation.data;
}