mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 01:53:30 +01:00
Make grammer gooder
This commit is contained in:
@@ -33,7 +33,7 @@ class ClientVoiceManager {
|
||||
*/
|
||||
_checkPendingReady(guildID) {
|
||||
const pendingRequest = this.pending.get(guildID);
|
||||
if (!pendingRequest) throw new Error('Guild not pending');
|
||||
if (!pendingRequest) throw new Error('Guild not pending.');
|
||||
if (pendingRequest.token && pendingRequest.sessionID && pendingRequest.endpoint) {
|
||||
const { channel, token, sessionID, endpoint, resolve, reject } = pendingRequest;
|
||||
const voiceConnection = new VoiceConnection(this, channel, token, sessionID, endpoint, resolve, reject);
|
||||
@@ -53,7 +53,7 @@ class ClientVoiceManager {
|
||||
*/
|
||||
_receivedVoiceServer(guildID, token, endpoint) {
|
||||
const pendingRequest = this.pending.get(guildID);
|
||||
if (!pendingRequest) throw new Error('Guild not pending');
|
||||
if (!pendingRequest) throw new Error('Guild not pending.');
|
||||
pendingRequest.token = token;
|
||||
// remove the port otherwise it errors ¯\_(ツ)_/¯
|
||||
pendingRequest.endpoint = endpoint.match(/([^:]*)/)[0];
|
||||
@@ -67,7 +67,7 @@ class ClientVoiceManager {
|
||||
*/
|
||||
_receivedVoiceStateUpdate(guildID, sessionID) {
|
||||
const pendingRequest = this.pending.get(guildID);
|
||||
if (!pendingRequest) throw new Error('Guild not pending');
|
||||
if (!pendingRequest) throw new Error('Guild not pending.');
|
||||
pendingRequest.sessionID = sessionID;
|
||||
this._checkPendingReady(guildID);
|
||||
}
|
||||
@@ -97,7 +97,9 @@ class ClientVoiceManager {
|
||||
*/
|
||||
joinChannel(channel) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.pending.get(channel.guild.id)) throw new Error('already connecting to a channel in this guild');
|
||||
if (this.pending.get(channel.guild.id)) {
|
||||
throw new Error(`Already connecting to a channel in guild.`);
|
||||
}
|
||||
const existingConn = this.connections.get(channel.guild.id);
|
||||
if (existingConn) {
|
||||
if (existingConn.channel.id !== channel.id) {
|
||||
@@ -116,7 +118,7 @@ class ClientVoiceManager {
|
||||
reject,
|
||||
});
|
||||
this._sendWSJoin(channel);
|
||||
this.client.setTimeout(() => reject(new Error('connection not established in 15s time period')), 15000);
|
||||
this.client.setTimeout(() => reject(new Error('Connection not established within 15 seconds.')), 15000);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ class StreamDispatcher extends EventEmitter {
|
||||
const data = this.streamingData;
|
||||
|
||||
if (data.missed >= 5) {
|
||||
this._triggerTerminalState('error', new Error('stream is not generating fast enough'));
|
||||
this._triggerTerminalState('error', new Error('Stream is not generating quickly enough.'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ class StreamDispatcher extends EventEmitter {
|
||||
* @event StreamDispatcher#debug
|
||||
* @param {string} information The debug information
|
||||
*/
|
||||
this.emit('debug', `triggered terminal state ${state} - stream is now dead`);
|
||||
this.emit('debug', `Triggered terminal state ${state} - stream is now dead`);
|
||||
this._triggered = true;
|
||||
this._setSpeaking(false);
|
||||
switch (state) {
|
||||
@@ -195,14 +195,14 @@ class StreamDispatcher extends EventEmitter {
|
||||
this._triggerError(err);
|
||||
break;
|
||||
default:
|
||||
this.emit('error', 'unknown trigger state');
|
||||
this.emit('error', 'Unknown trigger state');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_startStreaming() {
|
||||
if (!this.stream) {
|
||||
this.emit('error', 'no stream');
|
||||
this.emit('error', 'No stream');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,5 +20,5 @@ exports.fetch = () => {
|
||||
const fetched = fetch(encoder);
|
||||
if (fetched) return fetched;
|
||||
}
|
||||
throw new Error('could not find an opus engine');
|
||||
throw new Error('Couldn\'t find an Opus engine.');
|
||||
};
|
||||
|
||||
@@ -50,30 +50,30 @@ class VoiceConnectionPlayer extends EventEmitter {
|
||||
killStream(stream) {
|
||||
const streams = this.processMap.get(stream);
|
||||
this._streamingData = this.dispatcher.streamingData;
|
||||
this.emit('debug', 'cleaning up streams after end/error');
|
||||
this.emit('debug', 'Cleaning up streams after end/error');
|
||||
if (streams) {
|
||||
this.processMap.delete(stream);
|
||||
if (streams.inputStream && streams.pcmConverter) {
|
||||
try {
|
||||
if (streams.inputStream.unpipe) {
|
||||
streams.inputStream.unpipe(streams.pcmConverter.stdin);
|
||||
this.emit('debug', 'stream kill part 4/5 pass');
|
||||
this.emit('debug', 'Stream kill part 4/5 pass');
|
||||
}
|
||||
if (streams.pcmConverter.stdout.destroy) {
|
||||
streams.pcmConverter.stdout.destroy();
|
||||
this.emit('debug', 'stream kill part 2/5 pass');
|
||||
this.emit('debug', 'Stream kill part 2/5 pass');
|
||||
}
|
||||
if (streams.pcmConverter && streams.pcmConverter.kill) {
|
||||
streams.pcmConverter.kill('SIGINT');
|
||||
this.emit('debug', 'stream kill part 3/5 pass');
|
||||
this.emit('debug', 'Stream kill part 3/5 pass');
|
||||
}
|
||||
if (streams.pcmConverter.stdin) {
|
||||
streams.pcmConverter.stdin.end();
|
||||
this.emit('debug', 'stream kill part 1/5 pass');
|
||||
this.emit('debug', 'Stream kill part 1/5 pass');
|
||||
}
|
||||
if (streams.inputStream.destroy) {
|
||||
streams.inputStream.destroy();
|
||||
this.emit('debug', 'stream kill part 5/5 pass');
|
||||
this.emit('debug', 'Stream kill part 5/5 pass');
|
||||
}
|
||||
} catch (err) {
|
||||
return err;
|
||||
|
||||
@@ -34,9 +34,7 @@ class VoiceReceiver extends EventEmitter {
|
||||
const ssrc = +msg.readUInt32BE(8).toString(10);
|
||||
const user = this.connection.ssrcMap.get(ssrc);
|
||||
if (!user) {
|
||||
if (!this.queues.has(ssrc)) {
|
||||
this.queues.set(ssrc, []);
|
||||
}
|
||||
if (!this.queues.has(ssrc)) this.queues.set(ssrc, []);
|
||||
this.queues.get(ssrc).push(msg);
|
||||
} else {
|
||||
if (this.queues.get(ssrc)) {
|
||||
@@ -58,12 +56,8 @@ class VoiceReceiver extends EventEmitter {
|
||||
*/
|
||||
createOpusStream(user) {
|
||||
user = this.connection.manager.client.resolver.resolveUser(user);
|
||||
if (!user) {
|
||||
throw new Error('invalid user object supplied');
|
||||
}
|
||||
if (this.opusStreams.get(user.id)) {
|
||||
throw new Error('there is already an existing stream for that user!');
|
||||
}
|
||||
if (!user) throw new Error('Couldn\'t resolve the user to create Opus stream.');
|
||||
if (this.opusStreams.get(user.id)) throw new Error('There is already an existing stream for that user.');
|
||||
const stream = new Readable();
|
||||
this.opusStreams.set(user.id, stream);
|
||||
return stream;
|
||||
@@ -77,8 +71,8 @@ class VoiceReceiver extends EventEmitter {
|
||||
*/
|
||||
createPCMStream(user) {
|
||||
user = this.connection.manager.client.resolver.resolveUser(user);
|
||||
if (!user) throw new Error('invalid user object supplied');
|
||||
if (this.pcmStreams.get(user.id)) throw new Error('there is already an existing stream for that user!');
|
||||
if (!user) throw new Error('Couldn\'t resolve the user to create PCM stream.');
|
||||
if (this.pcmStreams.get(user.id)) throw new Error('There is already an existing stream for that user.');
|
||||
const stream = new Readable();
|
||||
this.pcmStreams.set(user.id, stream);
|
||||
return stream;
|
||||
@@ -93,7 +87,7 @@ class VoiceReceiver extends EventEmitter {
|
||||
* @event VoiceReceiver#warn
|
||||
* @param {string} message The warning message
|
||||
*/
|
||||
this.emit('warn', 'failed to decrypt voice packet');
|
||||
this.emit('warn', 'Failed to decrypt voice packet');
|
||||
return;
|
||||
}
|
||||
data = new Buffer(data);
|
||||
|
||||
Reference in New Issue
Block a user