mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 17:43:30 +01:00
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:
@@ -98,20 +98,20 @@ class Client extends BaseClient {
|
||||
: null;
|
||||
|
||||
/**
|
||||
* All of the {@link User} objects that have been cached at any point, mapped by their IDs
|
||||
* All of the {@link User} objects that have been cached at any point, mapped by their ids
|
||||
* @type {UserManager}
|
||||
*/
|
||||
this.users = new UserManager(this);
|
||||
|
||||
/**
|
||||
* All of the guilds the client is currently handling, mapped by their IDs -
|
||||
* All of the guilds the client is currently handling, mapped by their ids -
|
||||
* as long as sharding isn't being used, this will be *every* guild the bot is a member of
|
||||
* @type {GuildManager}
|
||||
*/
|
||||
this.guilds = new GuildManager(this);
|
||||
|
||||
/**
|
||||
* All of the {@link Channel}s that the client is currently handling, mapped by their IDs -
|
||||
* All of the {@link Channel}s that the client is currently handling, mapped by their ids -
|
||||
* as long as sharding isn't being used, this will be *every* channel in *every* guild the bot
|
||||
* is a member of. Note that DM channels will not be initially cached, and thus not be present
|
||||
* in the Manager without their explicit fetching or use.
|
||||
@@ -164,7 +164,7 @@ class Client extends BaseClient {
|
||||
}
|
||||
|
||||
/**
|
||||
* All custom emojis that the client has access to, mapped by their IDs
|
||||
* All custom emojis that the client has access to, mapped by their ids
|
||||
* @type {BaseGuildEmojiManager}
|
||||
* @readonly
|
||||
*/
|
||||
@@ -273,7 +273,7 @@ class Client extends BaseClient {
|
||||
|
||||
/**
|
||||
* Obtains a webhook from Discord.
|
||||
* @param {Snowflake} id ID of the webhook
|
||||
* @param {Snowflake} id The webhook's id
|
||||
* @param {string} [token] Token for the webhook
|
||||
* @returns {Promise<Webhook>}
|
||||
* @example
|
||||
@@ -352,7 +352,7 @@ class Client extends BaseClient {
|
||||
* @returns {Promise<GuildPreview>}
|
||||
*/
|
||||
fetchGuildPreview(guild) {
|
||||
const id = this.guilds.resolveID(guild);
|
||||
const id = this.guilds.resolveId(guild);
|
||||
if (!id) throw new TypeError('INVALID_TYPE', 'guild', 'GuildResolvable');
|
||||
return this.api
|
||||
.guilds(id)
|
||||
@@ -366,7 +366,7 @@ class Client extends BaseClient {
|
||||
* @returns {Promise<Widget>}
|
||||
*/
|
||||
async fetchWidget(guild) {
|
||||
const id = this.guilds.resolveID(guild);
|
||||
const id = this.guilds.resolveId(guild);
|
||||
if (!id) throw new TypeError('INVALID_TYPE', 'guild', 'GuildResolvable');
|
||||
const data = await this.api.guilds(id, 'widget.json').get();
|
||||
return new Widget(this, data);
|
||||
@@ -414,9 +414,9 @@ class Client extends BaseClient {
|
||||
}
|
||||
|
||||
if (options.guild) {
|
||||
const guildID = this.guilds.resolveID(options.guild);
|
||||
if (!guildID) throw new TypeError('INVALID_TYPE', 'options.guild', 'GuildResolvable');
|
||||
query.set('guild_id', guildID);
|
||||
const guildId = this.guilds.resolveId(options.guild);
|
||||
if (!guildId) throw new TypeError('INVALID_TYPE', 'options.guild', 'GuildResolvable');
|
||||
query.set('guild_id', guildId);
|
||||
}
|
||||
|
||||
if (options.additionalScopes) {
|
||||
|
||||
@@ -10,7 +10,7 @@ const Webhook = require('../structures/Webhook');
|
||||
*/
|
||||
class WebhookClient extends BaseClient {
|
||||
/**
|
||||
* @param {Snowflake} id ID of the webhook
|
||||
* @param {Snowflake} id The webhook's id
|
||||
* @param {string} token Token of the webhook
|
||||
* @param {ClientOptions} [options] Options for the client
|
||||
* @example
|
||||
|
||||
@@ -15,14 +15,14 @@ class MessageCreateAction extends Action {
|
||||
const message = channel.messages.add(data);
|
||||
const user = message.author;
|
||||
const member = message.member;
|
||||
channel.lastMessageID = data.id;
|
||||
channel.lastMessageId = data.id;
|
||||
if (user) {
|
||||
user.lastMessageID = data.id;
|
||||
user.lastMessageChannelID = channel.id;
|
||||
user.lastMessageId = data.id;
|
||||
user.lastMessageChannelId = channel.id;
|
||||
}
|
||||
if (member) {
|
||||
member.lastMessageID = data.id;
|
||||
member.lastMessageChannelID = channel.id;
|
||||
member.lastMessageId = data.id;
|
||||
member.lastMessageChannelId = channel.id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,7 +31,7 @@ class MessageDeleteBulkAction extends Action {
|
||||
/**
|
||||
* Emitted whenever messages are deleted in bulk.
|
||||
* @event Client#messageDeleteBulk
|
||||
* @param {Collection<Snowflake, Message>} messages The deleted messages, mapped by their ID
|
||||
* @param {Collection<Snowflake, Message>} messages The deleted messages, mapped by their id
|
||||
*/
|
||||
if (messages.size > 0) client.emit(Events.MESSAGE_BULK_DELETE, messages);
|
||||
return { messages };
|
||||
|
||||
@@ -16,14 +16,14 @@ class ClientVoiceManager {
|
||||
Object.defineProperty(this, 'client', { value: client });
|
||||
|
||||
/**
|
||||
* Maps guild IDs to voice adapters created for use with @discordjs/voice.
|
||||
* Maps guild ids to voice adapters created for use with @discordjs/voice.
|
||||
* @type {Map<Snowflake, Object>}
|
||||
*/
|
||||
this.adapters = new Map();
|
||||
|
||||
client.on(Events.SHARD_DISCONNECT, (_, shardID) => {
|
||||
for (const [guildID, adapter] of this.adapters.entries()) {
|
||||
if (client.guilds.cache.get(guildID)?.shardID === shardID) {
|
||||
client.on(Events.SHARD_DISCONNECT, (_, shardId) => {
|
||||
for (const [guildId, adapter] of this.adapters.entries()) {
|
||||
if (client.guilds.cache.get(guildId)?.shardId === shardId) {
|
||||
adapter.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 });
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user