@@ -36,10 +36,13 @@ const BeforeReadyWhitelist = [
36
36
37
37
const WaitingForGuildEvents = [ GatewayDispatchEvents . GuildCreate , GatewayDispatchEvents . GuildDelete ] ;
38
38
39
- const UNRESUMABLE_CLOSE_CODES = [
40
- CloseCodes . Normal ,
41
- GatewayCloseCodes . AlreadyAuthenticated ,
42
- GatewayCloseCodes . InvalidSeq ,
39
+ const UNRECOVERABLE_CLOSE_CODES = [
40
+ GatewayCloseCodes . AuthenticationFailed ,
41
+ GatewayCloseCodes . InvalidShard ,
42
+ GatewayCloseCodes . ShardingRequired ,
43
+ GatewayCloseCodes . InvalidAPIVersion ,
44
+ GatewayCloseCodes . InvalidIntents ,
45
+ GatewayCloseCodes . DisallowedIntents ,
43
46
] ;
44
47
45
48
const reasonIsDeprecated = 'the reason property is deprecated, use the code property to determine the reason' ;
@@ -242,7 +245,7 @@ class WebSocketManager extends EventEmitter {
242
245
this . _ws . on ( WSWebSocketShardEvents . Closed , ( { code, shardId } ) => {
243
246
const shard = this . shards . get ( shardId ) ;
244
247
shard . emit ( WebSocketShardEvents . Close , { code, reason : reasonIsDeprecated , wasClean : true } ) ;
245
- if ( UNRESUMABLE_CLOSE_CODES . includes ( code ) && this . destroyed ) {
248
+ if ( UNRECOVERABLE_CLOSE_CODES . includes ( code ) ) {
246
249
shard . status = Status . Disconnected ;
247
250
/**
248
251
* Emitted when a shard's WebSocket disconnects and will no longer reconnect.
@@ -251,7 +254,7 @@ class WebSocketManager extends EventEmitter {
251
254
* @param {number } id The shard id that disconnected
252
255
*/
253
256
this . client . emit ( Events . ShardDisconnect , { code, reason : reasonIsDeprecated , wasClean : true } , shardId ) ;
254
- this . debug ( [ `Shard not resumable : ${ code } (${ GatewayCloseCodes [ code ] ?? CloseCodes [ code ] } )` ] , shardId ) ;
257
+ this . debug ( [ `Shard not recoverable : ${ code } (${ GatewayCloseCodes [ code ] ?? CloseCodes [ code ] } )` ] , shardId ) ;
255
258
return ;
256
259
}
257
260
0 commit comments