mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
Add stricter/better ESLint config (#589)
* Add stricter/better ESLint config * Remove more unnecessary @returns
This commit is contained in:
committed by
Amish Shah
parent
2682c07bd8
commit
68acf37fd4
@@ -117,7 +117,7 @@ class Client extends EventEmitter {
|
||||
* @param {string} emailOrToken The email or token used for the account. If it is an email, a password _must_ be
|
||||
* provided.
|
||||
* @param {string} [password] The password for the account, only needed if an email was provided.
|
||||
* @return {Promise<string>}
|
||||
* @returns {Promise<string>}
|
||||
* @example
|
||||
* // log the client in using a token
|
||||
* const token = 'my token';
|
||||
@@ -128,13 +128,13 @@ class Client extends EventEmitter {
|
||||
* const password = 'supersecret123';
|
||||
* client.login(email, password);
|
||||
*/
|
||||
login(email, password) {
|
||||
login(emailOrToken, password) {
|
||||
if (password) {
|
||||
// login with email and password
|
||||
return this.rest.methods.loginEmailPassword(email, password);
|
||||
return this.rest.methods.loginEmailPassword(emailOrToken, password);
|
||||
}
|
||||
// login with token
|
||||
return this.rest.methods.loginToken(email);
|
||||
return this.rest.methods.loginToken(emailOrToken);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,7 +174,7 @@ class Client extends EventEmitter {
|
||||
}
|
||||
|
||||
syncGuilds(guilds = this.guilds.array()) {
|
||||
return this.ws.send({
|
||||
this.ws.send({
|
||||
op: 12,
|
||||
d: guilds.map(g => g.id),
|
||||
});
|
||||
@@ -184,7 +184,7 @@ class Client extends EventEmitter {
|
||||
* Caches a user, or obtains it from the cache if it's already cached.
|
||||
* If the user isn't already cached, it will only be obtainable by OAuth bot accounts.
|
||||
* @param {string} id The ID of the user to obtain
|
||||
* @return {Promise<User>}
|
||||
* @returns {Promise<User>}
|
||||
*/
|
||||
fetchUser(id) {
|
||||
if (this.users.has(id)) return Promise.resolve(this.users.get(id));
|
||||
|
||||
@@ -20,6 +20,7 @@ class ClientDataResolver {
|
||||
constructor(client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Data that resolves to give a User object. This can be:
|
||||
* * A User object
|
||||
@@ -80,15 +81,14 @@ class ClientDataResolver {
|
||||
* * A User object
|
||||
* @typedef {Guild} GuildMemberResolvable
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resolves a GuildMemberResolvable to a GuildMember object
|
||||
* @param {GuildResolvable} guild the guild that the member is part of
|
||||
* @param {UserResolvable} user the user that is part of the guild
|
||||
* @returns {?GuildMember}
|
||||
*/
|
||||
resolveGuildMember($guild, $user) {
|
||||
let guild = $guild;
|
||||
let user = $user;
|
||||
resolveGuildMember(guild, user) {
|
||||
if (user instanceof GuildMember) {
|
||||
return user;
|
||||
}
|
||||
@@ -112,7 +112,7 @@ class ClientDataResolver {
|
||||
|
||||
/**
|
||||
* Resolves a Base64Resolvable to a Base 64 image
|
||||
* @param {Base64Resolvable} dataResolvable the base 64 resolvable you want to resolve
|
||||
* @param {Base64Resolvable} data the base 64 resolvable you want to resolve
|
||||
* @returns {?string}
|
||||
*/
|
||||
resolveBase64(data) {
|
||||
@@ -132,7 +132,7 @@ class ClientDataResolver {
|
||||
|
||||
/**
|
||||
* Resolves a ChannelResolvable to a Channel object
|
||||
* @param {ChannelResolvable} channelResolvable the channel resolvable to resolve
|
||||
* @param {ChannelResolvable} channel the channel resolvable to resolve
|
||||
* @returns {?Channel}
|
||||
*/
|
||||
resolveChannel(channel) {
|
||||
@@ -157,7 +157,7 @@ class ClientDataResolver {
|
||||
|
||||
/**
|
||||
* Resolves a StringResolvable to a string
|
||||
* @param {StringResolvable} StringResolvable the string resolvable to resolve
|
||||
* @param {StringResolvable} data the string resolvable to resolve
|
||||
* @returns {string}
|
||||
*/
|
||||
resolveString(data) {
|
||||
@@ -176,13 +176,13 @@ class ClientDataResolver {
|
||||
* Data that can be resolved to give a Buffer. This can be:
|
||||
* * A Buffer
|
||||
* * The path to a local file
|
||||
* * An URL
|
||||
* * A URL
|
||||
* @typedef {string|Buffer} FileResolvable
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resolves a FileResolvable to a Buffer
|
||||
* @param {FileResolvable} fileResolvable the file resolvable to resolve
|
||||
* @param {FileResolvable} resource the file resolvable to resolve
|
||||
* @returns {string|Buffer}
|
||||
*/
|
||||
resolveFile(resource) {
|
||||
@@ -190,20 +190,18 @@ class ClientDataResolver {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (/^https?:\/\//.test(resource)) {
|
||||
request.get(resource)
|
||||
.set('Content-Type', 'blob')
|
||||
.end((err, res) => err ? reject(err) : resolve(res.body));
|
||||
.set('Content-Type', 'blob')
|
||||
.end((err, res) => err ? reject(err) : resolve(res.body));
|
||||
} else {
|
||||
const file = path.resolve(resource);
|
||||
const stat = fs.statSync(file);
|
||||
if (!stat.isFile()) {
|
||||
return reject(new Error(`The file could not be found: ${file}`));
|
||||
reject(new Error(`The file could not be found: ${file}`));
|
||||
return;
|
||||
}
|
||||
|
||||
fs.readFile(file, (err, data) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
resolve(data);
|
||||
if (err) reject(err); else resolve(data);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -24,7 +24,6 @@ class ClientManager {
|
||||
* @param {string} token the authorization token
|
||||
* @param {function} resolve function to run when connection is successful
|
||||
* @param {function} reject function to run when connection fails
|
||||
* @returns {void}
|
||||
*/
|
||||
connectToWebSocket(token, resolve, reject) {
|
||||
this.client.token = token;
|
||||
@@ -41,7 +40,6 @@ class ClientManager {
|
||||
/**
|
||||
* Sets up a keep-alive interval to keep the Client's connection valid
|
||||
* @param {number} time the interval in milliseconds at which heartbeat packets should be sent
|
||||
* @returns {void}
|
||||
*/
|
||||
setupKeepAlive(time) {
|
||||
this.heartbeatInterval = this.client.setInterval(() => {
|
||||
|
||||
@@ -417,9 +417,7 @@ class RESTMethods {
|
||||
}
|
||||
};
|
||||
this.rest.client.on(Constants.Events.GUILD_BAN_REMOVE, listener);
|
||||
this.rest.makeRequest('del', `${Constants.Endpoints.guildBans(guild.id)}/${member.id}`, true)
|
||||
.then(() => {})
|
||||
.catch(reject);
|
||||
this.rest.makeRequest('del', `${Constants.Endpoints.guildBans(guild.id)}/${member.id}`, true).catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class RequestHandler {
|
||||
* Attempts to get this RequestHandler to process its current queue
|
||||
*/
|
||||
handle() {
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,12 +99,13 @@ class ClientVoiceManager {
|
||||
/**
|
||||
* Sets up a request to join a voice channel
|
||||
* @param {VoiceChannel} channel the voice channel to join
|
||||
* @returns {void}
|
||||
* @returns {Promise<VoiceConnection>}
|
||||
*/
|
||||
joinChannel(channel) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.pending.get(channel.guild.id)) {
|
||||
return reject(new Error('already connecting to a channel in this guild'));
|
||||
reject(new Error('already connecting to a channel in this guild'));
|
||||
return;
|
||||
}
|
||||
const existingConn = this.connections.get(channel.guild.id);
|
||||
if (existingConn) {
|
||||
@@ -112,7 +113,8 @@ class ClientVoiceManager {
|
||||
this._sendWSJoin(channel);
|
||||
this.connections.get(channel.guild.id).channel = channel;
|
||||
}
|
||||
return resolve(existingConn);
|
||||
resolve(existingConn);
|
||||
return;
|
||||
}
|
||||
this.pending.set(channel.guild.id, {
|
||||
channel,
|
||||
|
||||
@@ -65,24 +65,22 @@ class VoiceConnection extends EventEmitter {
|
||||
/**
|
||||
* Executed whenever an error occurs with the UDP/WebSocket sub-client
|
||||
* @private
|
||||
* @param {Error} error
|
||||
* @returns {void}
|
||||
* @param {Error} err The error that occurred
|
||||
*/
|
||||
_onError(e) {
|
||||
this._reject(e);
|
||||
_onError(err) {
|
||||
this._reject(err);
|
||||
/**
|
||||
* Emitted whenever the connection encounters a fatal error.
|
||||
* @event VoiceConnection#error
|
||||
* @param {Error} error the encountered error
|
||||
*/
|
||||
this.emit('error', e);
|
||||
this._shutdown(e);
|
||||
this.emit('error', err);
|
||||
this._shutdown(err);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects the Client from the Voice Channel
|
||||
* @param {string} [reason='user requested'] the reason of the disconnection
|
||||
* @returns {void}
|
||||
*/
|
||||
disconnect(reason = 'user requested') {
|
||||
this.manager.client.ws.send({
|
||||
@@ -94,7 +92,7 @@ class VoiceConnection extends EventEmitter {
|
||||
self_deaf: false,
|
||||
},
|
||||
});
|
||||
return this._shutdown(reason);
|
||||
this._shutdown(reason);
|
||||
}
|
||||
|
||||
_onClose(e) {
|
||||
@@ -122,7 +120,6 @@ class VoiceConnection extends EventEmitter {
|
||||
|
||||
/**
|
||||
* Binds listeners to the WebSocket and UDP sub-clients
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
bindListeners() {
|
||||
@@ -208,7 +205,7 @@ class VoiceConnection extends EventEmitter {
|
||||
|
||||
/**
|
||||
* Play the given file in the voice connection
|
||||
* @param {string} filepath the path to the file
|
||||
* @param {string} file the path to the file
|
||||
* @returns {StreamDispatcher}
|
||||
* @example
|
||||
* // play files natively
|
||||
|
||||
@@ -16,7 +16,8 @@ class VoiceConnectionUDPClient extends EventEmitter {
|
||||
dnsLookup() {
|
||||
dns.lookup(this.voiceConnection.endpoint, (err, address) => {
|
||||
if (err) {
|
||||
return this.emit('error', err);
|
||||
this.emit('error', err);
|
||||
return;
|
||||
}
|
||||
this.connectUDP(address);
|
||||
});
|
||||
@@ -27,7 +28,7 @@ class VoiceConnectionUDPClient extends EventEmitter {
|
||||
try {
|
||||
this.udpSocket.send(packet, 0, packet.length, this.data.port, this.udpIP);
|
||||
} catch (err) {
|
||||
return this.emit('error', err);
|
||||
this.emit('error', err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,16 +51,18 @@ class VoiceConnectionWebSocket extends EventEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
_onClose(e) {
|
||||
_onClose(err) {
|
||||
if (!this.opened && this.attempts >= 0) {
|
||||
return this.setupWS();
|
||||
this.setupWS();
|
||||
return;
|
||||
}
|
||||
this.emit('close', e);
|
||||
this.emit('close', err);
|
||||
}
|
||||
|
||||
_onError(e) {
|
||||
if (!this.opened && this.attempts >= 0) {
|
||||
return this.setupWS();
|
||||
this.setupWS();
|
||||
return;
|
||||
}
|
||||
this.emit('error', e);
|
||||
}
|
||||
@@ -83,7 +85,8 @@ class VoiceConnectionWebSocket extends EventEmitter {
|
||||
try {
|
||||
packet = JSON.parse(event.data);
|
||||
} catch (error) {
|
||||
return this._onError(error);
|
||||
this._onError(error);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (packet.op) {
|
||||
|
||||
@@ -62,15 +62,18 @@ class StreamDispatcher extends EventEmitter {
|
||||
_send() {
|
||||
try {
|
||||
if (this._triggered) {
|
||||
return this._setSpeaking(false);
|
||||
this._setSpeaking(false);
|
||||
return;
|
||||
}
|
||||
const data = this.streamingData;
|
||||
if (data.missed >= 5) {
|
||||
return this._triggerTerminalState('error', new Error('stream is not generating fast enough'));
|
||||
this._triggerTerminalState('error', new Error('stream is not generating fast enough'));
|
||||
return;
|
||||
}
|
||||
if (this.paused) {
|
||||
data.timestamp = (data.timestamp + 4294967295) ? data.timestamp + 960 : 0;
|
||||
return this.player.connection.manager.client.setTimeout(() => this._send(), data.length * 10);
|
||||
data.timestamp = data.timestamp + 4294967295 ? data.timestamp + 960 : 0;
|
||||
this.player.connection.manager.client.setTimeout(() => this._send(), data.length * 10);
|
||||
return;
|
||||
}
|
||||
const bufferLength = 1920 * data.channels;
|
||||
this._setSpeaking(true);
|
||||
@@ -78,7 +81,8 @@ class StreamDispatcher extends EventEmitter {
|
||||
|
||||
if (!buffer) {
|
||||
data.missed++;
|
||||
return this.player.connection.manager.client.setTimeout(() => this._send(), data.length * 10);
|
||||
this.player.connection.manager.client.setTimeout(() => this._send(), data.length * 10);
|
||||
return;
|
||||
}
|
||||
|
||||
data.missed = 0;
|
||||
@@ -91,7 +95,7 @@ class StreamDispatcher extends EventEmitter {
|
||||
|
||||
data.count++;
|
||||
data.sequence = (data.sequence + 1) < (65536) ? data.sequence + 1 : 0;
|
||||
data.timestamp = (data.timestamp + 4294967295) ? data.timestamp + 960 : 0;
|
||||
data.timestamp = data.timestamp + 4294967295 ? data.timestamp + 960 : 0;
|
||||
|
||||
this._sendBuffer(buffer, data.sequence, data.timestamp);
|
||||
|
||||
@@ -114,14 +118,14 @@ class StreamDispatcher extends EventEmitter {
|
||||
/**
|
||||
* Emitted once the stream has encountered an error. Attach a `once` listener to this. Also emits `end`.
|
||||
* @event StreamDispatcher#error
|
||||
* @param {Error} error the error encountered
|
||||
* @param {Error} err the error encountered
|
||||
*/
|
||||
_triggerError(e) {
|
||||
_triggerError(err) {
|
||||
this.emit('end');
|
||||
this.emit('error', e);
|
||||
this.emit('error', err);
|
||||
}
|
||||
|
||||
_triggerTerminalState(state, e) {
|
||||
_triggerTerminalState(state, err) {
|
||||
if (this._triggered) {
|
||||
return;
|
||||
}
|
||||
@@ -136,10 +140,10 @@ class StreamDispatcher extends EventEmitter {
|
||||
this._setSpeaking(false);
|
||||
switch (state) {
|
||||
case 'end':
|
||||
this._triggerEnd(e);
|
||||
this._triggerEnd(err);
|
||||
break;
|
||||
case 'error':
|
||||
this._triggerError(e);
|
||||
this._triggerError(err);
|
||||
break;
|
||||
default:
|
||||
this.emit('error', 'unknown trigger state');
|
||||
@@ -149,10 +153,11 @@ class StreamDispatcher extends EventEmitter {
|
||||
|
||||
_startStreaming() {
|
||||
if (!this.stream) {
|
||||
return this.emit('error', 'no stream');
|
||||
this.emit('error', 'no stream');
|
||||
return;
|
||||
}
|
||||
this.stream.on('end', e => this._triggerTerminalState('end', e));
|
||||
this.stream.on('error', e => this._triggerTerminalState('error', e));
|
||||
this.stream.on('end', err => this._triggerTerminalState('end', err));
|
||||
this.stream.on('error', err => this._triggerTerminalState('error', err));
|
||||
const data = this.streamingData;
|
||||
data.length = 20;
|
||||
data.missed = 0;
|
||||
@@ -172,7 +177,6 @@ class StreamDispatcher extends EventEmitter {
|
||||
|
||||
/**
|
||||
* Stops the current stream permanently and emits an `end` event.
|
||||
* @returns {void}
|
||||
*/
|
||||
end() {
|
||||
this._triggerTerminalState('end', 'user requested');
|
||||
@@ -180,7 +184,6 @@ class StreamDispatcher extends EventEmitter {
|
||||
|
||||
/**
|
||||
* Stops sending voice packets to the voice connection (stream may still progress however)
|
||||
* @returns {void}
|
||||
*/
|
||||
pause() {
|
||||
this._pause(true);
|
||||
@@ -188,7 +191,6 @@ class StreamDispatcher extends EventEmitter {
|
||||
|
||||
/**
|
||||
* Resumes sending voice packets to the voice connection (may be further on in the stream than when paused)
|
||||
* @returns {void}
|
||||
*/
|
||||
resume() {
|
||||
this._pause(false);
|
||||
|
||||
@@ -11,7 +11,7 @@ function fetch(Encoder) {
|
||||
try {
|
||||
return new Encoder();
|
||||
} catch (err) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ function chooseCommand() {
|
||||
return cmd;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class FfmpegConverterEngine extends ConverterEngine {
|
||||
|
||||
@@ -70,11 +70,12 @@ class VoiceConnectionPlayer extends EventEmitter {
|
||||
streams.inputStream.destroy();
|
||||
this.emit('debug', 'stream kill part 5/5 pass');
|
||||
}
|
||||
} catch (e) {
|
||||
return e;
|
||||
} catch (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
setSpeaking(value) {
|
||||
|
||||
@@ -8,6 +8,7 @@ class VoiceReadable extends Readable {
|
||||
}
|
||||
|
||||
_read() {
|
||||
return;
|
||||
}
|
||||
|
||||
$push(d) {
|
||||
|
||||
@@ -91,7 +91,8 @@ class VoiceReceiver extends EventEmitter {
|
||||
* @event VoiceReceiver#warn
|
||||
* @param {string} message the warning message
|
||||
*/
|
||||
return this.emit('warn', 'failed to decrypt voice packet');
|
||||
this.emit('warn', 'failed to decrypt voice packet');
|
||||
return;
|
||||
}
|
||||
data = new Buffer(data);
|
||||
/**
|
||||
|
||||
@@ -49,7 +49,6 @@ class WebSocketManager {
|
||||
/**
|
||||
* Connects the client to a given gateway
|
||||
* @param {string} gateway the gateway to connect to
|
||||
* @returns {void}
|
||||
*/
|
||||
connect(gateway) {
|
||||
this.status = Constants.Status.CONNECTING;
|
||||
@@ -68,12 +67,13 @@ class WebSocketManager {
|
||||
|
||||
/**
|
||||
* Sends a packet to the gateway
|
||||
* @param {Object} packet An object that can be JSON stringified
|
||||
* @returns {void}
|
||||
* @param {Object} data An object that can be JSON stringified
|
||||
* @param {boolean} force Whether or not to send the packet immediately
|
||||
*/
|
||||
send(data, force = false) {
|
||||
if (force) {
|
||||
return this.ws.send(JSON.stringify(data));
|
||||
this.ws.send(JSON.stringify(data));
|
||||
return;
|
||||
}
|
||||
this._queue.push(JSON.stringify(data));
|
||||
this.doQueue();
|
||||
@@ -89,9 +89,10 @@ class WebSocketManager {
|
||||
const item = this._queue[0];
|
||||
if (this.ws.readyState === WebSocket.OPEN && item) {
|
||||
if (this._remaining === 0) {
|
||||
return this.client.setTimeout(() => {
|
||||
this.client.setTimeout(() => {
|
||||
this.doQueue();
|
||||
}, 1000);
|
||||
return;
|
||||
}
|
||||
this._remaining--;
|
||||
this.ws.send(item);
|
||||
@@ -103,7 +104,6 @@ class WebSocketManager {
|
||||
|
||||
/**
|
||||
* Run whenever the gateway connections opens up
|
||||
* @returns {void}
|
||||
*/
|
||||
eventOpen() {
|
||||
if (this.reconnecting) {
|
||||
@@ -115,7 +115,6 @@ class WebSocketManager {
|
||||
|
||||
/**
|
||||
* Sends a gatway resume packet, in cases of unexpected disconnections.
|
||||
* @returns {void}
|
||||
*/
|
||||
_sendResume() {
|
||||
const payload = {
|
||||
@@ -132,7 +131,6 @@ class WebSocketManager {
|
||||
|
||||
/**
|
||||
* Sends a new identification packet, in cases of new connections or failed reconnections.
|
||||
* @returns {void}
|
||||
*/
|
||||
_sendNewIdentify() {
|
||||
this.reconnecting = false;
|
||||
@@ -150,7 +148,7 @@ class WebSocketManager {
|
||||
|
||||
/**
|
||||
* Run whenever the connection to the gateway is closed, it will try to reconnect the client.
|
||||
* @returns {void}
|
||||
* @param {Object} event the event
|
||||
*/
|
||||
eventClose(event) {
|
||||
if (event.code === 4004) {
|
||||
@@ -164,12 +162,11 @@ class WebSocketManager {
|
||||
/**
|
||||
* Run whenever a message is received from the WebSocket. Returns `true` if the message
|
||||
* was handled properly.
|
||||
* @param {Object} data the received websocket data
|
||||
* @param {Object} event the received websocket data
|
||||
* @returns {boolean}
|
||||
*/
|
||||
eventMessage($event) {
|
||||
eventMessage(event) {
|
||||
let packet;
|
||||
const event = $event;
|
||||
try {
|
||||
if (event.binary) {
|
||||
event.data = zlib.inflateSync(event.data).toString();
|
||||
@@ -191,15 +188,15 @@ class WebSocketManager {
|
||||
|
||||
/**
|
||||
* Run whenever an error occurs with the WebSocket connection. Tries to reconnect
|
||||
* @returns {void}
|
||||
* @param {Error} err the error that occurred
|
||||
*/
|
||||
eventError(e) {
|
||||
eventError(err) {
|
||||
/**
|
||||
* Emitted whenever the Client encounters a serious connection error
|
||||
* @event Client#error
|
||||
* @param {Error} error the encountered error
|
||||
*/
|
||||
this.client.emit('error', e);
|
||||
this.client.emit('error', err);
|
||||
this.tryReconnect();
|
||||
}
|
||||
|
||||
@@ -217,7 +214,6 @@ class WebSocketManager {
|
||||
/**
|
||||
* Runs on new packets before `READY` to see if the Client is ready yet, if it is prepares
|
||||
* the `READY` event.
|
||||
* @returns {void}
|
||||
*/
|
||||
checkIfReady() {
|
||||
if (this.status !== Constants.Status.READY && this.status !== Constants.Status.NEARLY) {
|
||||
@@ -229,10 +225,11 @@ class WebSocketManager {
|
||||
this.status = Constants.Status.NEARLY;
|
||||
if (this.client.options.fetch_all_members) {
|
||||
const promises = this.client.guilds.array().map(g => g.fetchMembers());
|
||||
return Promise.all(promises).then(() => this._emitReady()).catch(e => {
|
||||
Promise.all(promises).then(() => this._emitReady()).catch(e => {
|
||||
this.client.emit('warn', `error on pre-ready guild member fetching - ${e}`);
|
||||
this._emitReady();
|
||||
});
|
||||
return;
|
||||
}
|
||||
this._emitReady();
|
||||
}
|
||||
@@ -241,7 +238,6 @@ class WebSocketManager {
|
||||
|
||||
/**
|
||||
* Tries to reconnect the client, changing the status to Constants.Status.RECONNECTING.
|
||||
* @returns {void}
|
||||
*/
|
||||
tryReconnect() {
|
||||
this.status = Constants.Status.RECONNECTING;
|
||||
|
||||
@@ -20,7 +20,7 @@ class ChannelPinsUpdate extends AbstractHandler {
|
||||
const time = new Date(data.last_pin_timestamp);
|
||||
|
||||
if (channel && time) {
|
||||
return client.emit(Constants.Events.CHANNEL_PINS_UPDATE, channel, time);
|
||||
client.emit(Constants.Events.CHANNEL_PINS_UPDATE, channel, time);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,14 +45,12 @@ class PresenceUpdateHandler extends AbstractHandler {
|
||||
data.user.status = data.status || user.status;
|
||||
data.user.game = data.game;
|
||||
|
||||
const same = (
|
||||
data.user.username === user.username &&
|
||||
const same = data.user.username === user.username &&
|
||||
data.user.id === user.id &&
|
||||
data.user.discriminator === user.discriminator &&
|
||||
data.user.avatar === user.avatar &&
|
||||
data.user.status === user.status &&
|
||||
JSON.stringify(data.user.game) === JSON.stringify(user.game)
|
||||
);
|
||||
JSON.stringify(data.user.game) === JSON.stringify(user.game);
|
||||
|
||||
if (!same) {
|
||||
const oldUser = cloneObject(user);
|
||||
|
||||
@@ -29,7 +29,7 @@ class ReadyHandler extends AbstractHandler {
|
||||
|
||||
this.packetManager.ws.sessionID = data.session_id;
|
||||
|
||||
this.packetManager.ws.checkIfReady('abc');
|
||||
this.packetManager.ws.checkIfReady();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user