mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 04:53:30 +01:00
More debug information
This commit is contained in:
@@ -64,7 +64,8 @@ class ClientVoiceManager {
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
connection = new VoiceConnection(this, channel);
|
connection = new VoiceConnection(this, channel);
|
||||||
connection.on('debug', msg => this.client.emit('debug', `[VOICE (${channel.guild.id})]: ${msg}`));
|
connection.on('debug', msg =>
|
||||||
|
this.client.emit('debug', `[VOICE (${channel.guild.id}:${connection.status})]: ${msg}`));
|
||||||
connection.authenticate();
|
connection.authenticate();
|
||||||
this.connections.set(channel.guild.id, connection);
|
this.connections.set(channel.guild.id, connection);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,6 +199,7 @@ class VoiceConnection extends EventEmitter {
|
|||||||
// Signifies awaiting endpoint stage
|
// Signifies awaiting endpoint stage
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.emit('debug', `Token "${token}" and endpoint "${endpoint}"`);
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
this.authenticateFailed('VOICE_TOKEN_ABSENT');
|
this.authenticateFailed('VOICE_TOKEN_ABSENT');
|
||||||
@@ -206,6 +207,7 @@ class VoiceConnection extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
endpoint = endpoint.match(/([^:]*)/)[0];
|
endpoint = endpoint.match(/([^:]*)/)[0];
|
||||||
|
this.emit('debug', `Endpoint resolved as ${endpoint}`);
|
||||||
|
|
||||||
if (!endpoint) {
|
if (!endpoint) {
|
||||||
this.authenticateFailed('VOICE_INVALID_ENDPOINT');
|
this.authenticateFailed('VOICE_INVALID_ENDPOINT');
|
||||||
@@ -252,7 +254,7 @@ class VoiceConnection extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
checkAuthenticated() {
|
checkAuthenticated() {
|
||||||
const { token, endpoint, sessionID } = this.authentication;
|
const { token, endpoint, sessionID } = this.authentication;
|
||||||
|
this.emit('debug', `Authenticated with sessionID ${sessionID}`);
|
||||||
if (token && endpoint && sessionID) {
|
if (token && endpoint && sessionID) {
|
||||||
this.status = VoiceStatus.CONNECTING;
|
this.status = VoiceStatus.CONNECTING;
|
||||||
/**
|
/**
|
||||||
@@ -271,6 +273,7 @@ class VoiceConnection extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
authenticateFailed(reason) {
|
authenticateFailed(reason) {
|
||||||
clearTimeout(this.connectTimeout);
|
clearTimeout(this.connectTimeout);
|
||||||
|
this.emit('debug', `Authenticate failed - ${reason}`);
|
||||||
if (this.status === VoiceStatus.AUTHENTICATING) {
|
if (this.status === VoiceStatus.AUTHENTICATING) {
|
||||||
/**
|
/**
|
||||||
* Emitted when we fail to initiate a voice connection.
|
* Emitted when we fail to initiate a voice connection.
|
||||||
@@ -320,6 +323,7 @@ class VoiceConnection extends EventEmitter {
|
|||||||
this.authentication.endpoint = endpoint;
|
this.authentication.endpoint = endpoint;
|
||||||
this.speaking = new Speaking().freeze();
|
this.speaking = new Speaking().freeze();
|
||||||
this.status = VoiceStatus.RECONNECTING;
|
this.status = VoiceStatus.RECONNECTING;
|
||||||
|
this.emit('debug', `Reconnecting to ${endpoint}`);
|
||||||
/**
|
/**
|
||||||
* Emitted when the voice connection is reconnecting (typically after a region change).
|
* Emitted when the voice connection is reconnecting (typically after a region change).
|
||||||
* @event VoiceConnection#reconnecting
|
* @event VoiceConnection#reconnecting
|
||||||
@@ -333,6 +337,7 @@ class VoiceConnection extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
disconnect() {
|
disconnect() {
|
||||||
this.emit('closing');
|
this.emit('closing');
|
||||||
|
this.emit('debug', 'disconnect() triggered');
|
||||||
clearTimeout(this.connectTimeout);
|
clearTimeout(this.connectTimeout);
|
||||||
const conn = this.voiceManager.connections.get(this.channel.guild.id);
|
const conn = this.voiceManager.connections.get(this.channel.guild.id);
|
||||||
if (conn === this) this.voiceManager.connections.delete(this.channel.guild.id);
|
if (conn === this) this.voiceManager.connections.delete(this.channel.guild.id);
|
||||||
@@ -366,6 +371,8 @@ class VoiceConnection extends EventEmitter {
|
|||||||
this.speaking = new Speaking().freeze();
|
this.speaking = new Speaking().freeze();
|
||||||
const { ws, udp } = this.sockets;
|
const { ws, udp } = this.sockets;
|
||||||
|
|
||||||
|
this.emit('debug', 'Connection clean up');
|
||||||
|
|
||||||
if (ws) {
|
if (ws) {
|
||||||
ws.removeAllListeners('error');
|
ws.removeAllListeners('error');
|
||||||
ws.removeAllListeners('ready');
|
ws.removeAllListeners('ready');
|
||||||
@@ -384,6 +391,7 @@ class VoiceConnection extends EventEmitter {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
connect() {
|
connect() {
|
||||||
|
this.emit('debug', `Connect triggered`);
|
||||||
if (this.status !== VoiceStatus.RECONNECTING) {
|
if (this.status !== VoiceStatus.RECONNECTING) {
|
||||||
if (this.sockets.ws) throw new Error('WS_CONNECTION_EXISTS');
|
if (this.sockets.ws) throw new Error('WS_CONNECTION_EXISTS');
|
||||||
if (this.sockets.udp) throw new Error('UDP_CONNECTION_EXISTS');
|
if (this.sockets.udp) throw new Error('UDP_CONNECTION_EXISTS');
|
||||||
|
|||||||
Reference in New Issue
Block a user