mirror of
https://github.com/danbulant/discord.js
synced 2026-07-07 04:00:42 +00:00
fix node.js crash due to error messages being called with invalid error keys (#1728)
* Comments * More Comments * Added new error message * Fixed error message * Removing temporary comments * Fixed error messages * Added more new error messages * Removed trailing space * Removed other trailing space * Changed error key * Changed error key used
This commit is contained in:
parent
79fed1295c
commit
4f5d1bffaf
2 changed files with 5 additions and 3 deletions
|
|
@ -65,7 +65,7 @@ class VoiceWebSocket extends EventEmitter {
|
||||||
if (this.dead) return;
|
if (this.dead) return;
|
||||||
if (this.ws) this.reset();
|
if (this.ws) this.reset();
|
||||||
if (this.attempts >= 5) {
|
if (this.attempts >= 5) {
|
||||||
this.emit('debug', new Error(`Too many connection attempts (${this.attempts}).`));
|
this.emit('debug', new Error('VOICE_CONNECTION_ATTEMPTS_EXCEEDED', this.attempts));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -123,7 +123,7 @@ class VoiceWebSocket extends EventEmitter {
|
||||||
session_id: this.voiceConnection.authentication.sessionID,
|
session_id: this.voiceConnection.authentication.sessionID,
|
||||||
},
|
},
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.emit('error', new Error('Tried to send join packet, but the WebSocket is not open.'));
|
this.emit('error', new Error('VOICE_JOIN_SOCKET_CLOSED'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -204,7 +204,7 @@ class VoiceWebSocket extends EventEmitter {
|
||||||
*/
|
*/
|
||||||
setHeartbeat(interval) {
|
setHeartbeat(interval) {
|
||||||
if (!interval || isNaN(interval)) {
|
if (!interval || isNaN(interval)) {
|
||||||
this.onError(new Error('Tried to set voice heartbeat but no valid interval was specified.'));
|
this.onError(new Error('VOICE_INVALID_HEARTBEAT'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.heartbeatInterval) {
|
if (this.heartbeatInterval) {
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,8 @@ const Messages = {
|
||||||
VOICE_SESSION_ABSENT: 'Session ID not supplied.',
|
VOICE_SESSION_ABSENT: 'Session ID not supplied.',
|
||||||
VOICE_INVALID_ENDPOINT: 'Invalid endpoint received.',
|
VOICE_INVALID_ENDPOINT: 'Invalid endpoint received.',
|
||||||
VOICE_NO_BROWSER: 'Voice connections are not available in browsers.',
|
VOICE_NO_BROWSER: 'Voice connections are not available in browsers.',
|
||||||
|
VOICE_CONNECTION_ATTEMPTS_EXCEEDED: attempts => `Too many connection attempts (${attempts}).`,
|
||||||
|
VOICE_JOIN_SOCKET_CLOSED: 'Tried to send join packet, but the WebSocket is not open.',
|
||||||
|
|
||||||
OPUS_ENGINE_MISSING: 'Couldn\'t find an Opus engine.',
|
OPUS_ENGINE_MISSING: 'Couldn\'t find an Opus engine.',
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue