refactor: change xID to xId (#6036)

* refactor: change `xID` to `xId`

* Update src/managers/MessageManager.js

Co-authored-by: Noel <buechler.noel@outlook.com>

Co-authored-by: Noel <buechler.noel@outlook.com>
This commit is contained in:
Antonio Román
2021-07-04 20:54:27 +02:00
committed by GitHub
parent 281072be44
commit a7c6678c72
95 changed files with 963 additions and 963 deletions

View File

@@ -174,8 +174,8 @@ class WebSocketManager extends EventEmitter {
/**
* Emitted when a shard turns ready.
* @event Client#shardReady
* @param {number} id The shard ID that turned ready
* @param {?Set<string>} unavailableGuilds Set of unavailable guild IDs, if any
* @param {number} id The shard id that turned ready
* @param {?Set<string>} unavailableGuilds Set of unavailable guild ids, if any
*/
this.client.emit(Events.SHARD_READY, shard.id, unavailableGuilds);
@@ -189,7 +189,7 @@ class WebSocketManager extends EventEmitter {
* Emitted when a shard's WebSocket disconnects and will no longer reconnect.
* @event Client#shardDisconnect
* @param {CloseEvent} event The WebSocket close event
* @param {number} id The shard ID that disconnected
* @param {number} id The shard id that disconnected
*/
this.client.emit(Events.SHARD_DISCONNECT, event, shard.id);
this.debug(WSCodes[event.code], shard);
@@ -198,20 +198,20 @@ class WebSocketManager extends EventEmitter {
if (UNRESUMABLE_CLOSE_CODES.includes(event.code)) {
// These event codes cannot be resumed
shard.sessionID = null;
shard.sessionId = null;
}
/**
* Emitted when a shard is attempting to reconnect or re-identify.
* @event Client#shardReconnecting
* @param {number} id The shard ID that is attempting to reconnect
* @param {number} id The shard id that is attempting to reconnect
*/
this.client.emit(Events.SHARD_RECONNECTING, shard.id);
this.shardQueue.add(shard);
if (shard.sessionID) {
this.debug(`Session ID is present, attempting an immediate reconnect...`, shard);
if (shard.sessionId) {
this.debug(`Session id is present, attempting an immediate reconnect...`, shard);
this.reconnect();
} else {
shard.destroy({ reset: true, emit: false, log: false });

View File

@@ -28,7 +28,7 @@ class WebSocketShard extends EventEmitter {
this.manager = manager;
/**
* The ID of the shard
* The shard's id
* @type {number}
*/
this.id = id;
@@ -54,11 +54,11 @@ class WebSocketShard extends EventEmitter {
this.closeSequence = 0;
/**
* The current session ID of the shard
* The current session id of the shard
* @type {?string}
* @private
*/
this.sessionID = null;
this.sessionId = null;
/**
* The previous heartbeat ping of the shard
@@ -134,7 +134,7 @@ class WebSocketShard extends EventEmitter {
Object.defineProperty(this, 'eventsAttached', { value: false, writable: true });
/**
* A set of guild IDs this shard expects to receive
* A set of guild ids this shard expects to receive
* @name WebSocketShard#expectedGuilds
* @type {?Set<string>}
* @private
@@ -313,7 +313,7 @@ class WebSocketShard extends EventEmitter {
* Emitted whenever a shard's WebSocket encounters a connection error.
* @event Client#shardError
* @param {Error} error The encountered error
* @param {number} shardID The shard that encountered this error
* @param {number} shardId The shard that encountered this error
*/
this.manager.client.emit(Events.SHARD_ERROR, error, this.id);
}
@@ -382,10 +382,10 @@ class WebSocketShard extends EventEmitter {
*/
this.emit(ShardEvents.READY);
this.sessionID = packet.d.session_id;
this.sessionId = packet.d.session_id;
this.expectedGuilds = new Set(packet.d.guilds.map(d => d.id));
this.status = Status.WAITING_FOR_GUILDS;
this.debug(`[READY] Session ${this.sessionID}.`);
this.debug(`[READY] Session ${this.sessionId}.`);
this.lastHeartbeatAcked = true;
this.sendHeartbeat('ReadyHeartbeat');
break;
@@ -398,7 +398,7 @@ class WebSocketShard extends EventEmitter {
this.status = Status.READY;
const replayed = packet.s - this.closeSequence;
this.debug(`[RESUMED] Session ${this.sessionID} | Replayed ${replayed} events.`);
this.debug(`[RESUMED] Session ${this.sessionId} | Replayed ${replayed} events.`);
this.lastHeartbeatAcked = true;
this.sendHeartbeat('ResumeHeartbeat');
break;
@@ -426,8 +426,8 @@ class WebSocketShard extends EventEmitter {
}
// Reset the sequence
this.sequence = -1;
// Reset the session ID as it's invalid
this.sessionID = null;
// Reset the session id as it's invalid
this.sessionId = null;
// Set the status to reconnecting
this.status = Status.RECONNECTING;
// Finally, emit the INVALID_SESSION event
@@ -576,7 +576,7 @@ class WebSocketShard extends EventEmitter {
* @returns {void}
*/
identify() {
return this.sessionID ? this.identifyResume() : this.identifyNew();
return this.sessionId ? this.identifyResume() : this.identifyNew();
}
/**
@@ -609,19 +609,19 @@ class WebSocketShard extends EventEmitter {
* @private
*/
identifyResume() {
if (!this.sessionID) {
this.debug('[RESUME] No session ID was present; identifying as a new session.');
if (!this.sessionId) {
this.debug('[RESUME] No session id was present; identifying as a new session.');
this.identifyNew();
return;
}
this.status = Status.RESUMING;
this.debug(`[RESUME] Session ${this.sessionID}, sequence ${this.closeSequence}`);
this.debug(`[RESUME] Session ${this.sessionId}, sequence ${this.closeSequence}`);
const d = {
token: this.manager.client.token,
session_id: this.sessionID,
session_id: this.sessionId,
seq: this.closeSequence,
};
@@ -731,10 +731,10 @@ class WebSocketShard extends EventEmitter {
// Step 4: Cache the old sequence (use to attempt a resume)
if (this.sequence !== -1) this.closeSequence = this.sequence;
// Step 5: Reset the sequence and session ID if requested
// Step 5: Reset the sequence and session id if requested
if (reset) {
this.sequence = -1;
this.sessionID = null;
this.sessionId = null;
}
// Step 6: reset the ratelimit data

View File

@@ -11,7 +11,7 @@ module.exports = (client, { d: data }, shard) => {
}
} else {
// A new guild
data.shardID = shard.id;
data.shardId = shard.id;
guild = client.guilds.add(data);
if (client.ws.status === Status.READY) {
/**

View File

@@ -13,7 +13,7 @@ module.exports = (client, { d: data }, shard) => {
}
for (const guild of data.guilds) {
guild.shardID = shard.id;
guild.shardId = shard.id;
client.guilds.add(guild);
}

View File

@@ -7,7 +7,7 @@ module.exports = (client, packet, shard) => {
/**
* Emitted when a shard resumes successfully.
* @event Client#shardResume
* @param {number} id The shard ID that resumed
* @param {number} id The shard id that resumed
* @param {number} replayedEvents The amount of replayed events
*/
client.emit(Events.SHARD_RESUME, shard.id, replayed);