mirror of
https://github.com/danbulant/discord.js
synced 2026-07-08 20:51:14 +00:00
Webpack build for branch wsrewrite: ce4ef50707340b00dc8b2fa65c98c9cd60fd1316
This commit is contained in:
parent
cf1ec84a51
commit
a036f3eb9d
2 changed files with 26 additions and 9 deletions
|
|
@ -142,6 +142,13 @@ exports.DefaultOptions = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.WSCodes = {
|
||||||
|
1000: 'Connection gracefully closed',
|
||||||
|
4004: 'Tried to identify with an invalid token',
|
||||||
|
4010: 'Sharding data provided was invalid',
|
||||||
|
4011: 'Shard would be on too many guilds if connected',
|
||||||
|
};
|
||||||
|
|
||||||
exports.Errors = {
|
exports.Errors = {
|
||||||
NO_TOKEN: 'Request to use token, but token was unavailable to the client.',
|
NO_TOKEN: 'Request to use token, but token was unavailable to the client.',
|
||||||
NO_BOT_ACCOUNT: 'Only bot accounts are able to make use of this feature.',
|
NO_BOT_ACCOUNT: 'Only bot accounts are able to make use of this feature.',
|
||||||
|
|
@ -16289,8 +16296,12 @@ class WebSocketConnection extends EventEmitter {
|
||||||
this.emit('close', event);
|
this.emit('close', event);
|
||||||
this.heartbeat(-1);
|
this.heartbeat(-1);
|
||||||
// Should we reconnect?
|
// Should we reconnect?
|
||||||
if (![1000, 4004, 4010, 4011].includes(event.code)) this.reconnect();
|
if (Constants.WSCodes[event.code]) {
|
||||||
else this.destroy();
|
this.debug(Constants.WSCodes[event.code]);
|
||||||
|
this.destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.reconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Heartbeat
|
// Heartbeat
|
||||||
|
|
@ -24744,10 +24755,13 @@ class WebSocketManager extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy the client
|
* Destroy the client
|
||||||
* @returns {boolean} Whether or not destruction was successful
|
* @returns {void} Whether or not destruction was successful
|
||||||
*/
|
*/
|
||||||
destroy() {
|
destroy() {
|
||||||
if (!this.connection) return this.debug('Attempted to destroy WebSocket but no connection exists!');
|
if (!this.connection) {
|
||||||
|
this.debug('Attempted to destroy WebSocket but no connection exists!');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return this.connection.destroy();
|
return this.connection.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -24757,8 +24771,11 @@ class WebSocketManager extends EventEmitter {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
send(packet) {
|
send(packet) {
|
||||||
if (!this.connection) return this.debug('No connection to websocket');
|
if (!this.connection) {
|
||||||
return this.connection.send(packet);
|
this.debug('No connection to websocket');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.connection.send(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
6
discord.wsrewrite.min.js
vendored
6
discord.wsrewrite.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue