Make grammer gooder

This commit is contained in:
Schuyler Cebulskie
2016-09-11 01:40:37 -04:00
parent 0833500d60
commit 47d71d32f3
15 changed files with 57 additions and 61 deletions

View File

@@ -199,7 +199,7 @@ class ClientDataResolver {
}
if (resource instanceof Buffer) return Promise.resolve(resource);
return Promise.reject(new TypeError('resource is not a string or Buffer'));
return Promise.reject(new TypeError('Resource must be a string or Buffer.'));
}
}

View File

@@ -25,10 +25,10 @@ class ClientManager {
* @param {function} reject Function to run when connection fails
*/
connectToWebSocket(token, resolve, reject) {
this.client.emit('debug', `authenticated using token ${token}`);
this.client.emit('debug', `Authenticated using token ${token}`);
this.client.token = token;
this.client.rest.methods.getGateway().then(gateway => {
this.client.emit('debug', `using gateway ${gateway}`);
this.client.emit('debug', `Using gateway ${gateway}`);
this.client.ws.connect(gateway);
this.client.once(Constants.Events.READY, () => resolve(token));
}).catch(reject);

View File

@@ -15,7 +15,7 @@ class RESTMethods {
loginEmailPassword(email, password) {
return new Promise((resolve, reject) => {
this.rest.client.emit('debug', 'client launched using email and password - should use token instead');
this.rest.client.emit('debug', 'Client launched using email and password - should use token instead');
this.rest.client.email = email;
this.rest.client.password = password;
this.rest.makeRequest('post', Constants.Endpoints.login, false, { email, password })
@@ -368,7 +368,7 @@ class RESTMethods {
banGuildMember(guild, member, deleteDays) {
return new Promise((resolve, reject) => {
const user = this.rest.client.resolver.resolveUser(member);
if (!user) throw new Error('cannot ban a user that is not a user resolvable');
if (!user) throw new Error('Couldn\'t resolve the user to ban.');
this.rest.makeRequest('put', `${Constants.Endpoints.guildBans(guild.id)}/${user.id}`, true, {
'delete-message-days': deleteDays,
}).then(() => {
@@ -380,7 +380,7 @@ class RESTMethods {
unbanGuildMember(guild, member) {
return new Promise((resolve, reject) => {
member = this.rest.client.resolver.resolveUser(member);
if (!member) throw new Error('cannot unban a user that is not a user resolvable');
if (!member) throw new Error('Couldn\'t resolve the user to unban.');
const listener = (eGuild, eUser) => {
if (guild.id === guild.id && member.id === eUser.id) {
this.rest.client.removeListener(Constants.Events.GUILD_BAN_REMOVE, listener);

View File

@@ -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);
});
}
}

View File

@@ -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;
}

View File

@@ -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.');
};

View File

@@ -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;

View File

@@ -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);

View File

@@ -56,7 +56,7 @@ class WebSocketManager {
* @param {string} gateway The gateway to connect to
*/
connect(gateway) {
this.client.emit('debug', `connecting to gateway ${gateway}`);
this.client.emit('debug', `Connecting to gateway ${gateway}`);
this.normalReady = false;
this.status = Constants.Status.CONNECTING;
this.ws = new WebSocket(gateway);
@@ -115,7 +115,7 @@ class WebSocketManager {
* Run whenever the gateway connections opens up
*/
eventOpen() {
this.client.emit('debug', 'connection to gateway opened');
this.client.emit('debug', 'Connection to gateway opened');
if (this.reconnecting) this._sendResume();
else this._sendNewIdentify();
}
@@ -224,7 +224,7 @@ class WebSocketManager {
if (this.client.options.fetch_all_members) {
const promises = this.client.guilds.array().map(g => g.fetchMembers());
Promise.all(promises).then(() => this._emitReady()).catch(e => {
this.client.emit('warn', `error on pre-ready guild member fetching - ${e}`);
this.client.emit('warn', `Error on pre-ready guild member fetching - ${e}`);
this._emitReady();
});
return;