Skip to content

Commit

Permalink
Handle 4011 ws event code (#1083)
Browse files Browse the repository at this point in the history
* 4011

* Update WebSocketManager.js

* smh gawdl3y
  • Loading branch information
devsnek authored and amishshah committed Jan 11, 2017
1 parent b2822c5 commit a3091f5
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/client/ClientManager.js
Expand Up @@ -35,6 +35,7 @@ class ClientManager {
this.client.ws.once('close', event => {
if (event.code === 4004) reject(new Error(Constants.Errors.BAD_LOGIN));
if (event.code === 4010) reject(new Error(Constants.Errors.INVALID_SHARD));
if (event.code === 4011) reject(new Error(Constants.Errors.SHARDING_REQUIRED));
});
this.client.once(Constants.Events.READY, () => {
resolve(token);
Expand Down
3 changes: 1 addition & 2 deletions src/client/websocket/WebSocketManager.js
Expand Up @@ -249,8 +249,7 @@ class WebSocketManager extends EventEmitter {
* @param {CloseEvent} event The WebSocket close event
*/
if (!this.reconnecting) this.client.emit(Constants.Events.DISCONNECT, event);
if (event.code === 4004) return;
if (event.code === 4010) return;
if ([4004, 4010, 4011].includes(event.code)) return;
if (!this.reconnecting && event.code !== 1000) this.tryReconnect();
}

Expand Down
1 change: 0 additions & 1 deletion src/structures/interface/TextBasedChannel.js
Expand Up @@ -2,7 +2,6 @@ const path = require('path');
const Message = require('../Message');
const MessageCollector = require('../MessageCollector');
const Collection = require('../../util/Collection');
let GuildMember;

/**
* Interface for classes that have text-channel-like features
Expand Down
1 change: 1 addition & 0 deletions src/util/Constants.js
Expand Up @@ -72,6 +72,7 @@ exports.Errors = {
INVALID_RATE_LIMIT_METHOD: 'Unknown rate limiting method.',
BAD_LOGIN: 'Incorrect login details were provided.',
INVALID_SHARD: 'Invalid shard settings were provided.',
SHARDING_REQUIRED: 'This session would have handled too many guilds - Sharding is required.',
INVALID_TOKEN: 'An invalid token was provided.',
};

Expand Down

1 comment on commit a3091f5

@TobiTenno
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for this, since we were just talking about this in api

Please sign in to comment.