diff --git a/src/client/actions/Action.js b/src/client/actions/Action.js index 743faad0f..10de53702 100644 --- a/src/client/actions/Action.js +++ b/src/client/actions/Action.js @@ -26,7 +26,7 @@ class GenericAction { getPayload(data, manager, id, partialType, cache) { const existing = manager.cache.get(id); if (!existing && this.client.options.partials.includes(partialType)) { - return manager.add(data, cache); + return manager._add(data, cache); } return existing; } @@ -93,9 +93,9 @@ class GenericAction { if (data.guild_id && data.member?.user) { const guild = this.client.guilds.cache.get(data.guild_id); if (guild) { - return guild.members.add(data.member).user; + return guild.members._add(data.member).user; } else { - return this.client.users.add(data.member.user); + return this.client.users._add(data.member.user); } } return this.getUser(data); diff --git a/src/client/actions/ChannelCreate.js b/src/client/actions/ChannelCreate.js index d1660aa76..68eb2dc06 100644 --- a/src/client/actions/ChannelCreate.js +++ b/src/client/actions/ChannelCreate.js @@ -7,7 +7,7 @@ class ChannelCreateAction extends Action { handle(data) { const client = this.client; const existing = client.channels.cache.has(data.id); - const channel = client.channels.add(data); + const channel = client.channels._add(data); if (!existing && channel) { /** * Emitted whenever a guild channel is created. diff --git a/src/client/actions/ChannelDelete.js b/src/client/actions/ChannelDelete.js index 9b3bd4cb0..ad5cffd9a 100644 --- a/src/client/actions/ChannelDelete.js +++ b/src/client/actions/ChannelDelete.js @@ -15,7 +15,7 @@ class ChannelDeleteAction extends Action { const channel = client.channels.cache.get(data.id); if (channel) { - client.channels.remove(channel.id); + client.channels._remove(channel.id); channel.deleted = true; if (channel.messages && !(channel instanceof DMChannel)) { for (const message of channel.messages.cache.values()) { diff --git a/src/client/actions/ChannelUpdate.js b/src/client/actions/ChannelUpdate.js index ac875a32d..6fd2e95cc 100644 --- a/src/client/actions/ChannelUpdate.js +++ b/src/client/actions/ChannelUpdate.js @@ -25,7 +25,7 @@ class ChannelUpdateAction extends Action { updated: channel, }; } else { - client.channels.add(data); + client.channels._add(data); } return {}; diff --git a/src/client/actions/GuildBanAdd.js b/src/client/actions/GuildBanAdd.js index 2efe16347..e97e789fe 100644 --- a/src/client/actions/GuildBanAdd.js +++ b/src/client/actions/GuildBanAdd.js @@ -13,7 +13,7 @@ class GuildBanAdd extends Action { * @event Client#guildBanAdd * @param {GuildBan} ban The ban that occurred */ - if (guild) client.emit(Events.GUILD_BAN_ADD, guild.bans.add(data)); + if (guild) client.emit(Events.GUILD_BAN_ADD, guild.bans._add(data)); } } diff --git a/src/client/actions/GuildDelete.js b/src/client/actions/GuildDelete.js index 89877fe89..057acbce7 100644 --- a/src/client/actions/GuildDelete.js +++ b/src/client/actions/GuildDelete.js @@ -36,7 +36,7 @@ class GuildDeleteAction extends Action { }; } - for (const channel of guild.channels.cache.values()) this.client.channels.remove(channel.id); + for (const channel of guild.channels.cache.values()) this.client.channels._remove(channel.id); client.voice.adapters.get(data.id)?.destroy(); // Delete guild diff --git a/src/client/actions/GuildEmojiCreate.js b/src/client/actions/GuildEmojiCreate.js index f47ddd5f2..ccc634cc8 100644 --- a/src/client/actions/GuildEmojiCreate.js +++ b/src/client/actions/GuildEmojiCreate.js @@ -6,7 +6,7 @@ const { Events } = require('../../util/Constants'); class GuildEmojiCreateAction extends Action { handle(guild, createdEmoji) { const already = guild.emojis.cache.has(createdEmoji.id); - const emoji = guild.emojis.add(createdEmoji); + const emoji = guild.emojis._add(createdEmoji); /** * Emitted whenever a custom emoji is created in a guild. * @event Client#emojiCreate diff --git a/src/client/actions/GuildMemberUpdate.js b/src/client/actions/GuildMemberUpdate.js index 20edfc7b2..137351f45 100644 --- a/src/client/actions/GuildMemberUpdate.js +++ b/src/client/actions/GuildMemberUpdate.js @@ -9,7 +9,7 @@ class GuildMemberUpdateAction extends Action { if (data.user.username) { const user = client.users.cache.get(data.user.id); if (!user) { - client.users.add(data.user); + client.users._add(data.user); } else if (!user.equals(data.user)) { client.actions.UserUpdate.handle(data.user); } @@ -29,7 +29,7 @@ class GuildMemberUpdateAction extends Action { */ if (shard.status === Status.READY && !member.equals(old)) client.emit(Events.GUILD_MEMBER_UPDATE, old, member); } else { - const newMember = guild.members.add(data); + const newMember = guild.members._add(data); /** * Emitted whenever a member becomes available in a large guild. * @event Client#guildMemberAvailable diff --git a/src/client/actions/GuildRoleCreate.js b/src/client/actions/GuildRoleCreate.js index d7d521445..102e0f633 100644 --- a/src/client/actions/GuildRoleCreate.js +++ b/src/client/actions/GuildRoleCreate.js @@ -10,7 +10,7 @@ class GuildRoleCreate extends Action { let role; if (guild) { const already = guild.roles.cache.has(data.role.id); - role = guild.roles.add(data.role); + role = guild.roles._add(data.role); /** * Emitted whenever a role is created. * @event Client#roleCreate diff --git a/src/client/actions/InviteCreate.js b/src/client/actions/InviteCreate.js index 6aee0b95d..ec6088d3d 100644 --- a/src/client/actions/InviteCreate.js +++ b/src/client/actions/InviteCreate.js @@ -11,7 +11,7 @@ class InviteCreateAction extends Action { if (!channel) return false; const inviteData = Object.assign(data, { channel, guild }); - const invite = guild.invites.add(inviteData); + const invite = guild.invites._add(inviteData); /** * Emitted when an invite is created. diff --git a/src/client/actions/MessageCreate.js b/src/client/actions/MessageCreate.js index 060f2a504..979a65cc8 100644 --- a/src/client/actions/MessageCreate.js +++ b/src/client/actions/MessageCreate.js @@ -12,7 +12,7 @@ class MessageCreateAction extends Action { if (channel) { const existing = channel.messages.cache.get(data.id); if (existing) return { message: existing }; - const message = channel.messages.add(data); + const message = channel.messages._add(data); channel.lastMessageId = data.id; /** diff --git a/src/client/actions/MessageReactionAdd.js b/src/client/actions/MessageReactionAdd.js index 6107d5dd3..e483ff512 100644 --- a/src/client/actions/MessageReactionAdd.js +++ b/src/client/actions/MessageReactionAdd.js @@ -33,7 +33,7 @@ class MessageReactionAdd extends Action { if (message.partial && !this.client.options.partials.includes(PartialTypes.REACTION)) return false; const existing = message.reactions.cache.get(data.emoji.id ?? data.emoji.name); if (existing?.users.cache.has(user.id)) return { message, reaction: existing, user }; - const reaction = message.reactions.add({ + const reaction = message.reactions._add({ emoji: data.emoji, count: message.partial ? null : 0, me: user.id === this.client.user.id, diff --git a/src/client/actions/PresenceUpdate.js b/src/client/actions/PresenceUpdate.js index 5eb29a610..3639ec3b4 100644 --- a/src/client/actions/PresenceUpdate.js +++ b/src/client/actions/PresenceUpdate.js @@ -6,7 +6,7 @@ const { Events } = require('../../util/Constants'); class PresenceUpdateAction extends Action { handle(data) { let user = this.client.users.cache.get(data.user.id); - if (!user && data.user?.username) user = this.client.users.add(data.user); + if (!user && data.user?.username) user = this.client.users._add(data.user); if (!user) return; if (data.user?.username) { @@ -19,14 +19,14 @@ class PresenceUpdateAction extends Action { const oldPresence = guild.presences.cache.get(user.id)?._clone() ?? null; let member = guild.members.cache.get(user.id); if (!member && data.status !== 'offline') { - member = guild.members.add({ + member = guild.members._add({ user, deaf: false, mute: false, }); this.client.emit(Events.GUILD_MEMBER_AVAILABLE, member); } - guild.presences.add(Object.assign(data, { guild })); + guild.presences._add(Object.assign(data, { guild })); if (this.client.listenerCount(Events.PRESENCE_UPDATE) && member && !member.presence.equals(oldPresence)) { /** * Emitted whenever a guild member's presence (e.g. status, activity) is changed. diff --git a/src/client/actions/StageInstanceCreate.js b/src/client/actions/StageInstanceCreate.js index 75b94bdd3..bff459152 100644 --- a/src/client/actions/StageInstanceCreate.js +++ b/src/client/actions/StageInstanceCreate.js @@ -9,7 +9,7 @@ class StageInstanceCreateAction extends Action { const channel = this.getChannel(data); if (channel) { - const stageInstance = channel.guild.stageInstances.add(data); + const stageInstance = channel.guild.stageInstances._add(data); /** * Emitted whenever a stage instance is created. diff --git a/src/client/actions/StageInstanceDelete.js b/src/client/actions/StageInstanceDelete.js index b665996a3..01e948d9c 100644 --- a/src/client/actions/StageInstanceDelete.js +++ b/src/client/actions/StageInstanceDelete.js @@ -9,7 +9,7 @@ class StageInstanceDeleteAction extends Action { const channel = this.getChannel(data); if (channel) { - const stageInstance = channel.guild.stageInstances.add(data); + const stageInstance = channel.guild.stageInstances._add(data); if (stageInstance) { channel.guild.stageInstances.cache.delete(stageInstance.id); stageInstance.deleted = true; diff --git a/src/client/actions/StageInstanceUpdate.js b/src/client/actions/StageInstanceUpdate.js index a13788e41..17d74f951 100644 --- a/src/client/actions/StageInstanceUpdate.js +++ b/src/client/actions/StageInstanceUpdate.js @@ -10,7 +10,7 @@ class StageInstanceUpdateAction extends Action { if (channel) { const oldStageInstance = channel.guild.stageInstances.cache.get(data.id)?._clone() ?? null; - const newStageInstance = channel.guild.stageInstances.add(data); + const newStageInstance = channel.guild.stageInstances._add(data); /** * Emitted whenever a stage instance gets updated - e.g. change in topic or privacy level diff --git a/src/client/actions/ThreadCreate.js b/src/client/actions/ThreadCreate.js index a9a62c04d..f7c36e678 100644 --- a/src/client/actions/ThreadCreate.js +++ b/src/client/actions/ThreadCreate.js @@ -7,7 +7,7 @@ class ThreadCreateAction extends Action { handle(data) { const client = this.client; const existing = client.channels.cache.has(data.id); - const thread = client.channels.add(data); + const thread = client.channels._add(data); if (!existing && thread) { /** * Emitted whenever a thread is created or when the client user is added to a thread. diff --git a/src/client/actions/ThreadDelete.js b/src/client/actions/ThreadDelete.js index 67761d4bf..6a23f8e6d 100644 --- a/src/client/actions/ThreadDelete.js +++ b/src/client/actions/ThreadDelete.js @@ -9,7 +9,7 @@ class ThreadDeleteAction extends Action { const thread = client.channels.cache.get(data.id); if (thread) { - client.channels.remove(thread.id); + client.channels._remove(thread.id); thread.deleted = true; for (const message of thread.messages.cache.values()) { message.deleted = true; diff --git a/src/client/actions/ThreadListSync.js b/src/client/actions/ThreadListSync.js index 444e42bf4..fa1254078 100644 --- a/src/client/actions/ThreadListSync.js +++ b/src/client/actions/ThreadListSync.js @@ -23,7 +23,7 @@ class ThreadListSyncAction extends Action { } const syncedThreads = data.threads.reduce((coll, rawThread) => { - const thread = client.channels.add(rawThread); + const thread = client.channels._add(rawThread); return coll.set(thread.id, thread); }, new Collection()); @@ -50,7 +50,7 @@ class ThreadListSyncAction extends Action { removeStale(channel) { channel.threads?.cache.forEach(thread => { if (!thread.archived) { - this.client.channels.remove(thread.id); + this.client.channels._remove(thread.id); } }); } diff --git a/src/client/actions/VoiceStateUpdate.js b/src/client/actions/VoiceStateUpdate.js index a01191a37..f750e048b 100644 --- a/src/client/actions/VoiceStateUpdate.js +++ b/src/client/actions/VoiceStateUpdate.js @@ -13,14 +13,14 @@ class VoiceStateUpdate extends Action { const oldState = guild.voiceStates.cache.get(data.user_id)?._clone() ?? new VoiceState(guild, { user_id: data.user_id }); - const newState = guild.voiceStates.add(data); + const newState = guild.voiceStates._add(data); // Get the member let member = guild.members.cache.get(data.user_id); if (member && data.member) { member._patch(data.member); } else if (data.member?.user && data.member.joined_at) { - member = guild.members.add(data.member); + member = guild.members._add(data.member); } // Emit event diff --git a/src/client/websocket/handlers/APPLICATION_COMMAND_CREATE.js b/src/client/websocket/handlers/APPLICATION_COMMAND_CREATE.js index 9d7125a89..f81a2b520 100644 --- a/src/client/websocket/handlers/APPLICATION_COMMAND_CREATE.js +++ b/src/client/websocket/handlers/APPLICATION_COMMAND_CREATE.js @@ -8,9 +8,9 @@ module.exports = (client, { d: data }) => { if (data.guild_id) { const guild = client.guilds.cache.get(data.guild_id); if (!guild) return; - command = guild.commands.add(data); + command = guild.commands._add(data); } else { - command = client.application.commands.add(data); + command = client.application.commands._add(data); } /** diff --git a/src/client/websocket/handlers/APPLICATION_COMMAND_DELETE.js b/src/client/websocket/handlers/APPLICATION_COMMAND_DELETE.js index c0eb3008a..99cc93526 100644 --- a/src/client/websocket/handlers/APPLICATION_COMMAND_DELETE.js +++ b/src/client/websocket/handlers/APPLICATION_COMMAND_DELETE.js @@ -8,10 +8,10 @@ module.exports = (client, { d: data }) => { if (data.guild_id) { const guild = client.guilds.cache.get(data.guild_id); if (!guild) return; - command = guild.commands.add(data); + command = guild.commands._add(data); guild.commands.cache.delete(data.id); } else { - command = client.application.commands.add(data); + command = client.application.commands._add(data); client.application.commands.cache.delete(data.id); } diff --git a/src/client/websocket/handlers/APPLICATION_COMMAND_UPDATE.js b/src/client/websocket/handlers/APPLICATION_COMMAND_UPDATE.js index d2708eecf..252ed56fb 100644 --- a/src/client/websocket/handlers/APPLICATION_COMMAND_UPDATE.js +++ b/src/client/websocket/handlers/APPLICATION_COMMAND_UPDATE.js @@ -10,10 +10,10 @@ module.exports = (client, { d: data }) => { const guild = client.guilds.cache.get(data.guild_id); if (!guild) return; oldCommand = guild.commands.cache.get(data.id)?._clone() ?? null; - newCommand = guild.commands.add(data); + newCommand = guild.commands._add(data); } else { oldCommand = client.application.commands.cache.get(data.id)?._clone() ?? null; - newCommand = client.application.commands.add(data); + newCommand = client.application.commands._add(data); } /** diff --git a/src/client/websocket/handlers/GUILD_CREATE.js b/src/client/websocket/handlers/GUILD_CREATE.js index 02e449f0e..acff7c285 100644 --- a/src/client/websocket/handlers/GUILD_CREATE.js +++ b/src/client/websocket/handlers/GUILD_CREATE.js @@ -12,7 +12,7 @@ module.exports = (client, { d: data }, shard) => { } else { // A new guild data.shardId = shard.id; - guild = client.guilds.add(data); + guild = client.guilds._add(data); if (client.ws.status === Status.READY) { /** * Emitted whenever the client joins a guild. diff --git a/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js b/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js index 2a04c68b1..1e4c3e267 100644 --- a/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +++ b/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js @@ -8,9 +8,9 @@ module.exports = (client, { d: data }) => { if (!guild) return; const members = new Collection(); - for (const member of data.members) members.set(member.user.id, guild.members.add(member)); + for (const member of data.members) members.set(member.user.id, guild.members._add(member)); if (data.presences) { - for (const presence of data.presences) guild.presences.add(Object.assign(presence, { guild })); + for (const presence of data.presences) guild.presences._add(Object.assign(presence, { guild })); } /** * Emitted whenever a chunk of guild members is received (all members come from the same guild). diff --git a/src/client/websocket/handlers/GUILD_MEMBER_ADD.js b/src/client/websocket/handlers/GUILD_MEMBER_ADD.js index 512875621..67590db20 100644 --- a/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +++ b/src/client/websocket/handlers/GUILD_MEMBER_ADD.js @@ -6,7 +6,7 @@ module.exports = (client, { d: data }, shard) => { const guild = client.guilds.cache.get(data.guild_id); if (guild) { guild.memberCount++; - const member = guild.members.add(data); + const member = guild.members._add(data); if (shard.status === Status.READY) { /** * Emitted whenever a user joins a guild. diff --git a/src/client/websocket/handlers/READY.js b/src/client/websocket/handlers/READY.js index f81bc7fd3..408bfa732 100644 --- a/src/client/websocket/handlers/READY.js +++ b/src/client/websocket/handlers/READY.js @@ -14,7 +14,7 @@ module.exports = (client, { d: data }, shard) => { for (const guild of data.guilds) { guild.shardId = shard.id; - client.guilds.add(guild); + client.guilds._add(guild); } if (client.application) { diff --git a/src/managers/ApplicationCommandManager.js b/src/managers/ApplicationCommandManager.js index 1ed20a670..7b7c8dc70 100644 --- a/src/managers/ApplicationCommandManager.js +++ b/src/managers/ApplicationCommandManager.js @@ -27,8 +27,8 @@ class ApplicationCommandManager extends CachedManager { * @name ApplicationCommandManager#cache */ - add(data, cache, guildId) { - return super.add(data, cache, { extras: [this.guild, guildId] }); + _add(data, cache, guildId) { + return super._add(data, cache, { extras: [this.guild, guildId] }); } /** @@ -90,11 +90,11 @@ class ApplicationCommandManager extends CachedManager { if (existing) return existing; } const command = await this.commandPath({ id, guildId }).get(); - return this.add(command, cache); + return this._add(command, cache); } const data = await this.commandPath({ guildId }).get(); - return data.reduce((coll, command) => coll.set(command.id, this.add(command, cache, guildId)), new Collection()); + return data.reduce((coll, command) => coll.set(command.id, this._add(command, cache, guildId)), new Collection()); } /** @@ -116,7 +116,7 @@ class ApplicationCommandManager extends CachedManager { const data = await this.commandPath({ guildId }).post({ data: this.constructor.transformCommand(command), }); - return this.add(data, undefined, guildId); + return this._add(data, undefined, guildId); } /** @@ -146,7 +146,7 @@ class ApplicationCommandManager extends CachedManager { data: commands.map(c => this.constructor.transformCommand(c)), }); return data.reduce( - (coll, command) => coll.set(command.id, this.add(command, undefined, guildId)), + (coll, command) => coll.set(command.id, this._add(command, undefined, guildId)), new Collection(), ); } @@ -171,7 +171,7 @@ class ApplicationCommandManager extends CachedManager { if (!id) throw new TypeError('INVALID_TYPE', 'command', 'ApplicationCommandResolvable'); const patched = await this.commandPath({ id, guildId }).patch({ data: this.constructor.transformCommand(data) }); - return this.add(patched, undefined, guildId); + return this._add(patched, undefined, guildId); } /** diff --git a/src/managers/CachedManager.js b/src/managers/CachedManager.js index 78ecfc6e1..1a3856853 100644 --- a/src/managers/CachedManager.js +++ b/src/managers/CachedManager.js @@ -15,7 +15,7 @@ class CachedManager extends DataManager { if (iterable) { for (const item of iterable) { - this.add(item); + this._add(item); } } } @@ -29,7 +29,7 @@ class CachedManager extends DataManager { return this._cache; } - add(data, cache = true, { id, extras = [] } = {}) { + _add(data, cache = true, { id, extras = [] } = {}) { const existing = this.cache.get(id ?? data.id); if (cache) existing?._patch(data); if (existing) return existing; diff --git a/src/managers/ChannelManager.js b/src/managers/ChannelManager.js index e28af76c6..4de961bc2 100644 --- a/src/managers/ChannelManager.js +++ b/src/managers/ChannelManager.js @@ -19,13 +19,13 @@ class ChannelManager extends CachedManager { * @name ChannelManager#cache */ - add(data, guild, cache = true, allowUnknownGuild = false) { + _add(data, guild, cache = true, allowUnknownGuild = false) { const existing = this.cache.get(data.id); if (existing) { if (cache) existing._patch(data); - guild?.channels?.add(existing); + guild?.channels?._add(existing); if (ThreadChannelTypes.includes(existing.type)) { - existing.parent?.threads?.add(existing); + existing.parent?.threads?._add(existing); } return existing; } @@ -42,7 +42,7 @@ class ChannelManager extends CachedManager { return channel; } - remove(id) { + _remove(id) { const channel = this.cache.get(id); channel?.guild?.channels.cache.delete(id); channel?.parent?.threads?.cache.delete(id); @@ -99,7 +99,7 @@ class ChannelManager extends CachedManager { } const data = await this.client.api.channels(id).get(); - return this.add(data, null, cache, allowUnknownGuild); + return this._add(data, null, cache, allowUnknownGuild); } } diff --git a/src/managers/GuildBanManager.js b/src/managers/GuildBanManager.js index 9b05c4b79..fcedc71fe 100644 --- a/src/managers/GuildBanManager.js +++ b/src/managers/GuildBanManager.js @@ -27,8 +27,8 @@ class GuildBanManager extends CachedManager { * @name GuildBanManager#cache */ - add(data, cache) { - return super.add(data, cache, { id: data.user.id, extras: [this.guild] }); + _add(data, cache) { + return super._add(data, cache, { id: data.user.id, extras: [this.guild] }); } /** @@ -110,12 +110,12 @@ class GuildBanManager extends CachedManager { } const data = await this.client.api.guilds(this.guild.id).bans(user).get(); - return this.add(data, cache); + return this._add(data, cache); } async _fetchMany(cache) { const data = await this.client.api.guilds(this.guild.id).bans.get(); - return data.reduce((col, ban) => col.set(ban.user.id, this.add(ban, cache)), new Collection()); + return data.reduce((col, ban) => col.set(ban.user.id, this._add(ban, cache)), new Collection()); } /** diff --git a/src/managers/GuildChannelManager.js b/src/managers/GuildChannelManager.js index 62c8102fc..be5ea0531 100644 --- a/src/managers/GuildChannelManager.js +++ b/src/managers/GuildChannelManager.js @@ -42,7 +42,7 @@ class GuildChannelManager extends CachedManager { * @name GuildChannelManager#cache */ - add(channel) { + _add(channel) { const existing = this.cache.get(channel.id); if (existing) return existing; this.cache.set(channel.id, channel); @@ -169,12 +169,12 @@ class GuildChannelManager extends CachedManager { const data = await this.client.api.channels(id).get(); // Since this is the guild manager, throw if on a different guild if (this.guild.id !== data.guild_id) throw new Error('GUILD_CHANNEL_UNOWNED'); - return this.client.channels.add(data, this.guild, cache); + return this.client.channels._add(data, this.guild, cache); } const data = await this.client.api.guilds(this.guild.id).channels.get(); const channels = new Collection(); - for (const channel of data) channels.set(channel.id, this.client.channels.add(channel, this.guild, cache)); + for (const channel of data) channels.set(channel.id, this.client.channels._add(channel, this.guild, cache)); return channels; } } diff --git a/src/managers/GuildEmojiManager.js b/src/managers/GuildEmojiManager.js index f64c4d71a..bffb09ef8 100644 --- a/src/managers/GuildEmojiManager.js +++ b/src/managers/GuildEmojiManager.js @@ -20,8 +20,8 @@ class GuildEmojiManager extends BaseGuildEmojiManager { this.guild = guild; } - add(data, cache) { - return super.add(data, cache, { extras: [this.guild] }); + _add(data, cache) { + return super._add(data, cache, { extras: [this.guild] }); } /** @@ -94,12 +94,12 @@ class GuildEmojiManager extends BaseGuildEmojiManager { if (existing) return existing; } const emoji = await this.client.api.guilds(this.guild.id).emojis(id).get(); - return this.add(emoji, cache); + return this._add(emoji, cache); } const data = await this.client.api.guilds(this.guild.id).emojis.get(); const emojis = new Collection(); - for (const emoji of data) emojis.set(emoji.id, this.add(emoji, cache)); + for (const emoji of data) emojis.set(emoji.id, this._add(emoji, cache)); return emojis; } } diff --git a/src/managers/GuildInviteManager.js b/src/managers/GuildInviteManager.js index 45cd05547..ea4f1dccb 100644 --- a/src/managers/GuildInviteManager.js +++ b/src/managers/GuildInviteManager.js @@ -27,8 +27,8 @@ class GuildInviteManager extends CachedManager { * @name GuildInviteManager#cache */ - add(data, cache) { - return super.add(data, cache, { id: data.code, extras: [this.guild] }); + _add(data, cache) { + return super._add(data, cache, { id: data.code, extras: [this.guild] }); } /** @@ -142,12 +142,12 @@ class GuildInviteManager extends CachedManager { async _fetchMany(cache) { const data = await this.client.api.guilds(this.guild.id).invites.get(); - return data.reduce((col, invite) => col.set(invite.code, this.add(invite, cache)), new Collection()); + return data.reduce((col, invite) => col.set(invite.code, this._add(invite, cache)), new Collection()); } async _fetchChannelMany(channelID, cache) { const data = await this.client.api.channels(channelID).invites.get(); - return data.reduce((col, invite) => col.set(invite.code, this.add(invite, cache)), new Collection()); + return data.reduce((col, invite) => col.set(invite.code, this._add(invite, cache)), new Collection()); } /** diff --git a/src/managers/GuildManager.js b/src/managers/GuildManager.js index 1914ad7c2..39f77034b 100644 --- a/src/managers/GuildManager.js +++ b/src/managers/GuildManager.js @@ -229,7 +229,7 @@ class GuildManager extends CachedManager { const timeout = this.client.setTimeout(() => { this.client.removeListener(Events.GUILD_CREATE, handleGuild); this.client.decrementMaxListeners(); - resolve(this.client.guilds.add(data)); + resolve(this.client.guilds._add(data)); }, 10000); return undefined; }, reject), @@ -265,7 +265,7 @@ class GuildManager extends CachedManager { } const data = await this.client.api.guilds(id).get({ query: { with_counts: true } }); - return this.add(data, options.cache); + return this._add(data, options.cache); } const data = await this.client.api.users('@me').guilds.get({ query: options }); diff --git a/src/managers/GuildMemberManager.js b/src/managers/GuildMemberManager.js index a56e9e3f8..1c923f468 100644 --- a/src/managers/GuildMemberManager.js +++ b/src/managers/GuildMemberManager.js @@ -30,8 +30,8 @@ class GuildMemberManager extends CachedManager { * @name GuildMemberManager#cache */ - add(data, cache = true) { - return super.add(data, cache, { id: data.user.id, extras: [this.guild] }); + _add(data, cache = true) { + return super._add(data, cache, { id: data.user.id, extras: [this.guild] }); } /** @@ -152,7 +152,7 @@ class GuildMemberManager extends CachedManager { */ async search({ query, limit = 1, cache = true } = {}) { const data = await this.client.api.guilds(this.guild.id).members.search.get({ query: { query, limit } }); - return data.reduce((col, member) => col.set(member.user.id, this.add(member, cache)), new Collection()); + return data.reduce((col, member) => col.set(member.user.id, this._add(member, cache)), new Collection()); } /** @@ -193,7 +193,7 @@ class GuildMemberManager extends CachedManager { const clone = this.cache.get(id)?._clone(); clone?._patch(d); - return clone ?? this.add(d, false); + return clone ?? this._add(d, false); } /** @@ -326,7 +326,7 @@ class GuildMemberManager extends CachedManager { .guilds(this.guild.id) .members(user) .get() - .then(data => this.add(data, cache)); + .then(data => this._add(data, cache)); } _fetchMany({ diff --git a/src/managers/MessageManager.js b/src/managers/MessageManager.js index 0c5bad26b..e36de7c9d 100644 --- a/src/managers/MessageManager.js +++ b/src/managers/MessageManager.js @@ -27,8 +27,8 @@ class MessageManager extends CachedManager { * @name MessageManager#cache */ - add(data, cache) { - return super.add(data, cache, { extras: [this.channel] }); + _add(data, cache) { + return super._add(data, cache, { extras: [this.channel] }); } /** @@ -83,7 +83,7 @@ class MessageManager extends CachedManager { fetchPinned(cache = true) { return this.client.api.channels[this.channel.id].pins.get().then(data => { const messages = new Collection(); - for (const message of data) messages.set(message.id, this.add(message, cache)); + for (const message of data) messages.set(message.id, this._add(message, cache)); return messages; }); } @@ -137,7 +137,7 @@ class MessageManager extends CachedManager { clone._patch(d); return clone; } - return this.add(d); + return this._add(d); } /** @@ -150,7 +150,7 @@ class MessageManager extends CachedManager { if (!message) throw new TypeError('INVALID_TYPE', 'message', 'MessageResolvable'); const data = await this.client.api.channels(this.channel.id).messages(message).crosspost.post(); - return this.cache.get(data.id) ?? this.add(data); + return this.cache.get(data.id) ?? this._add(data); } /** @@ -213,13 +213,13 @@ class MessageManager extends CachedManager { } const data = await this.client.api.channels[this.channel.id].messages[messageId].get(); - return this.add(data, cache); + return this._add(data, cache); } async _fetchMany(options = {}, cache) { const data = await this.client.api.channels[this.channel.id].messages.get({ query: options }); const messages = new Collection(); - for (const message of data) messages.set(message.id, this.add(message, cache)); + for (const message of data) messages.set(message.id, this._add(message, cache)); return messages; } } diff --git a/src/managers/PermissionOverwriteManager.js b/src/managers/PermissionOverwriteManager.js index 8d6cd127b..91c3e03ce 100644 --- a/src/managers/PermissionOverwriteManager.js +++ b/src/managers/PermissionOverwriteManager.js @@ -28,8 +28,8 @@ class PermissionOverwriteManager extends CachedManager { * @name PermissionOverwriteManager#cache */ - add(data, cache) { - return super.add(data, cache, { extras: [this.channel] }); + _add(data, cache) { + return super._add(data, cache, { extras: [this.channel] }); } /** diff --git a/src/managers/PresenceManager.js b/src/managers/PresenceManager.js index bd342bc81..2d6483425 100644 --- a/src/managers/PresenceManager.js +++ b/src/managers/PresenceManager.js @@ -18,8 +18,8 @@ class PresenceManager extends CachedManager { * @name PresenceManager#cache */ - add(data, cache) { - return super.add(data, cache, { id: data.user.id }); + _add(data, cache) { + return super._add(data, cache, { id: data.user.id }); } /** diff --git a/src/managers/ReactionManager.js b/src/managers/ReactionManager.js index 2a325c2e5..771e05416 100644 --- a/src/managers/ReactionManager.js +++ b/src/managers/ReactionManager.js @@ -18,8 +18,8 @@ class ReactionManager extends CachedManager { this.message = message; } - add(data, cache) { - return super.add(data, cache, { id: data.emoji.id ?? data.emoji.name, extras: [this.message] }); + _add(data, cache) { + return super._add(data, cache, { id: data.emoji.id ?? data.emoji.name, extras: [this.message] }); } /** diff --git a/src/managers/ReactionUserManager.js b/src/managers/ReactionUserManager.js index f1bbab696..403c1df42 100644 --- a/src/managers/ReactionUserManager.js +++ b/src/managers/ReactionUserManager.js @@ -45,7 +45,7 @@ class ReactionUserManager extends CachedManager { ].get({ query: { limit, after } }); const users = new Collection(); for (const rawUser of data) { - const user = this.client.users.add(rawUser); + const user = this.client.users._add(rawUser); this.cache.set(user.id, user); users.set(user.id, user); } diff --git a/src/managers/RoleManager.js b/src/managers/RoleManager.js index 9b68ba9ed..a92cbb334 100644 --- a/src/managers/RoleManager.js +++ b/src/managers/RoleManager.js @@ -28,8 +28,8 @@ class RoleManager extends CachedManager { * @name RoleManager#cache */ - add(data, cache) { - return super.add(data, cache, { extras: [this.guild] }); + _add(data, cache) { + return super._add(data, cache, { extras: [this.guild] }); } /** @@ -57,7 +57,7 @@ class RoleManager extends CachedManager { // We cannot fetch a single role, as of this commit's date, Discord API throws with 405 const data = await this.client.api.guilds(this.guild.id).roles.get(); const roles = new Collection(); - for (const role of data) roles.set(role.id, this.add(role, cache)); + for (const role of data) roles.set(role.id, this._add(role, cache)); return id ? roles.get(id) ?? null : roles; } diff --git a/src/managers/StageInstanceManager.js b/src/managers/StageInstanceManager.js index da55260d8..d3684a9a6 100644 --- a/src/managers/StageInstanceManager.js +++ b/src/managers/StageInstanceManager.js @@ -63,7 +63,7 @@ class StageInstanceManager extends CachedManager { }, }); - return this.add(data); + return this._add(data); } /** @@ -87,7 +87,7 @@ class StageInstanceManager extends CachedManager { } const data = await this.client.api('stage-instances', channelId).get(); - return this.add(data, cache); + return this._add(data, cache); } /** @@ -130,7 +130,7 @@ class StageInstanceManager extends CachedManager { return clone; } - return this.add(data); + return this._add(data); } /** diff --git a/src/managers/ThreadManager.js b/src/managers/ThreadManager.js index afa2d4b1b..2e334f051 100644 --- a/src/managers/ThreadManager.js +++ b/src/managers/ThreadManager.js @@ -27,7 +27,7 @@ class ThreadManager extends CachedManager { * @name ThreadManager#cache */ - add(thread) { + _add(thread) { const existing = this.cache.get(thread.id); if (existing) return existing; this.cache.set(thread.id, thread); @@ -234,7 +234,7 @@ class ThreadManager extends CachedManager { _mapThreads(rawThreads, cache) { const threads = rawThreads.threads.reduce((coll, raw) => { - const thread = this.client.channels.add(raw, null, cache); + const thread = this.client.channels._add(raw, null, cache); return coll.set(thread.id, thread); }, new Collection()); // Discord sends the thread id as id in this object diff --git a/src/managers/UserManager.js b/src/managers/UserManager.js index 118a3712b..dfbba9e89 100644 --- a/src/managers/UserManager.js +++ b/src/managers/UserManager.js @@ -67,7 +67,7 @@ class UserManager extends CachedManager { } const data = await this.client.api.users(id).get(); - return this.add(data, cache); + return this._add(data, cache); } } diff --git a/src/managers/VoiceStateManager.js b/src/managers/VoiceStateManager.js index d33c5ba72..c42fdd2c3 100644 --- a/src/managers/VoiceStateManager.js +++ b/src/managers/VoiceStateManager.js @@ -24,7 +24,7 @@ class VoiceStateManager extends CachedManager { * @name VoiceStateManager#cache */ - add(data, cache = true) { + _add(data, cache = true) { const existing = this.cache.get(data.user_id); if (existing) return existing._patch(data); diff --git a/src/structures/BaseGuild.js b/src/structures/BaseGuild.js index 963d8c6c0..05e029bb7 100644 --- a/src/structures/BaseGuild.js +++ b/src/structures/BaseGuild.js @@ -101,7 +101,7 @@ class BaseGuild extends Base { */ async fetch() { const data = await this.client.api.guilds(this.id).get({ query: { with_counts: true } }); - return this.client.guilds.add(data); + return this.client.guilds._add(data); } /** diff --git a/src/structures/ClientApplication.js b/src/structures/ClientApplication.js index 5c9e1a4c2..4eb95a6c4 100644 --- a/src/structures/ClientApplication.js +++ b/src/structures/ClientApplication.js @@ -60,7 +60,7 @@ class ClientApplication extends Application { this.owner = data.team ? new Team(this.client, data.team) : data.owner - ? this.client.users.add(data.owner) + ? this.client.users._add(data.owner) : this.owner ?? null; } diff --git a/src/structures/CommandInteraction.js b/src/structures/CommandInteraction.js index 7eb6c7290..f2504a295 100644 --- a/src/structures/CommandInteraction.js +++ b/src/structures/CommandInteraction.js @@ -112,16 +112,16 @@ class CommandInteraction extends Interaction { if (resolved) { const user = resolved.users?.[option.value]; - if (user) result.user = this.client.users.add(user); + if (user) result.user = this.client.users._add(user); const member = resolved.members?.[option.value]; - if (member) result.member = this.guild?.members.add({ user, ...member }) ?? member; + if (member) result.member = this.guild?.members._add({ user, ...member }) ?? member; const channel = resolved.channels?.[option.value]; - if (channel) result.channel = this.client.channels.add(channel, this.guild) ?? channel; + if (channel) result.channel = this.client.channels._add(channel, this.guild) ?? channel; const role = resolved.roles?.[option.value]; - if (role) result.role = this.guild?.roles.add(role) ?? role; + if (role) result.role = this.guild?.roles._add(role) ?? role; } return result; diff --git a/src/structures/DMChannel.js b/src/structures/DMChannel.js index 5fff4c11b..f4b635eff 100644 --- a/src/structures/DMChannel.js +++ b/src/structures/DMChannel.js @@ -34,7 +34,7 @@ class DMChannel extends Channel { * The recipient on the other end of the DM * @type {User} */ - this.recipient = this.client.users.add(data.recipients[0]); + this.recipient = this.client.users._add(data.recipients[0]); } /** diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 6f1dcf1e8..57b1e5d00 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -343,24 +343,24 @@ class Guild extends AnonymousGuild { if (data.channels) { this.channels.cache.clear(); for (const rawChannel of data.channels) { - this.client.channels.add(rawChannel, this); + this.client.channels._add(rawChannel, this); } } if (data.threads) { for (const rawThread of data.threads) { - this.client.channels.add(rawThread, this); + this.client.channels._add(rawThread, this); } } if (data.roles) { this.roles.cache.clear(); - for (const role of data.roles) this.roles.add(role); + for (const role of data.roles) this.roles._add(role); } if (data.members) { this.members.cache.clear(); - for (const guildUser of data.members) this.members.add(guildUser); + for (const guildUser of data.members) this.members._add(guildUser); } if (data.owner_id) { @@ -373,21 +373,21 @@ class Guild extends AnonymousGuild { if (data.presences) { for (const presence of data.presences) { - this.presences.add(Object.assign(presence, { guild: this })); + this.presences._add(Object.assign(presence, { guild: this })); } } if (data.stage_instances) { this.stageInstances.cache.clear(); for (const stageInstance of data.stage_instances) { - this.stageInstances.add(stageInstance); + this.stageInstances._add(stageInstance); } } if (data.voice_states) { this.voiceStates.cache.clear(); for (const voiceState of data.voice_states) { - this.voiceStates.add(voiceState); + this.voiceStates._add(voiceState); } } @@ -397,7 +397,7 @@ class Guild extends AnonymousGuild { * @type {GuildEmojiManager} */ this.emojis = new GuildEmojiManager(this); - if (data.emojis) for (const emoji of data.emojis) this.emojis.add(emoji); + if (data.emojis) for (const emoji of data.emojis) this.emojis._add(emoji); } else if (data.emojis) { this.client.actions.GuildEmojisUpdate.handle({ guild_id: this.id, @@ -513,7 +513,7 @@ class Guild extends AnonymousGuild { return ( this.members.resolve(this.client.user.id) ?? (this.client.options.partials.includes(PartialTypes.GUILD_MEMBER) - ? this.members.add({ user: { id: this.client.user.id } }, true) + ? this.members._add({ user: { id: this.client.user.id } }, true) : null) ); } @@ -759,7 +759,7 @@ class Guild extends AnonymousGuild { } const data = await this.client.api.guilds(this.id).members(user).put({ data: options }); // Data is an empty buffer if the member is already part of the guild. - return data instanceof Buffer ? this.members.fetch(user) : this.members.add(data); + return data instanceof Buffer ? this.members.fetch(user) : this.members._add(data); } /** diff --git a/src/structures/GuildAuditLogs.js b/src/structures/GuildAuditLogs.js index 6680af2ce..7fefa09fc 100644 --- a/src/structures/GuildAuditLogs.js +++ b/src/structures/GuildAuditLogs.js @@ -140,7 +140,7 @@ const Actions = { */ class GuildAuditLogs { constructor(guild, data) { - if (data.users) for (const user of data.users) guild.client.users.add(user); + if (data.users) for (const user of data.users) guild.client.users._add(user); /** * Cached webhooks * @type {Collection} @@ -340,7 +340,7 @@ class GuildAuditLogsEntry { */ this.executor = data.user_id ? guild.client.options.partials.includes(PartialTypes.USER) - ? guild.client.users.add({ id: data.user_id }) + ? guild.client.users._add({ id: data.user_id }) : guild.client.users.cache.get(data.user_id) : null; @@ -450,7 +450,7 @@ class GuildAuditLogsEntry { // MEMBER_DISCONNECT and similar types do not provide a target_id. } else if (targetType === Targets.USER && data.target_id) { this.target = guild.client.options.partials.includes(PartialTypes.USER) - ? guild.client.users.add({ id: data.target_id }) + ? guild.client.users._add({ id: data.target_id }) : guild.client.users.cache.get(data.target_id); } else if (targetType === Targets.GUILD) { this.target = guild.client.guilds.cache.get(data.target_id); diff --git a/src/structures/GuildBan.js b/src/structures/GuildBan.js index 9a14d4de8..b40e7c3ac 100644 --- a/src/structures/GuildBan.js +++ b/src/structures/GuildBan.js @@ -29,7 +29,7 @@ class GuildBan extends Base { * The user this ban applies to * @type {User} */ - this.user = this.client.users.add(data.user, true); + this.user = this.client.users._add(data.user, true); if ('reason' in data) { /** diff --git a/src/structures/GuildChannel.js b/src/structures/GuildChannel.js index 598b6c6fa..e97962e3a 100644 --- a/src/structures/GuildChannel.js +++ b/src/structures/GuildChannel.js @@ -85,7 +85,7 @@ class GuildChannel extends Channel { if ('permission_overwrites' in data) { this.permissionOverwrites.cache.clear(); for (const overwrite of data.permission_overwrites) { - this.permissionOverwrites.add(overwrite); + this.permissionOverwrites._add(overwrite); } } } diff --git a/src/structures/GuildEmoji.js b/src/structures/GuildEmoji.js index dc586a1e9..0359abebb 100644 --- a/src/structures/GuildEmoji.js +++ b/src/structures/GuildEmoji.js @@ -48,7 +48,7 @@ class GuildEmoji extends BaseGuildEmoji { _patch(data) { super._patch(data); - if (data.user) this.author = this.client.users.add(data.user); + if (data.user) this.author = this.client.users._add(data.user); if (data.roles) this._roles = data.roles; } diff --git a/src/structures/GuildMember.js b/src/structures/GuildMember.js index c097b7b15..b640c904a 100644 --- a/src/structures/GuildMember.js +++ b/src/structures/GuildMember.js @@ -67,7 +67,7 @@ class GuildMember extends Base { * The user that this guild member instance represents * @type {User} */ - this.user = this.client.users.add(data.user, true); + this.user = this.client.users._add(data.user, true); } if ('nick' in data) this.nickname = data.nick; diff --git a/src/structures/GuildTemplate.js b/src/structures/GuildTemplate.js index 123fa18bd..6697e535d 100644 --- a/src/structures/GuildTemplate.js +++ b/src/structures/GuildTemplate.js @@ -59,7 +59,7 @@ class GuildTemplate extends Base { * The user that created this template * @type {User} */ - this.creator = this.client.users.add(data.creator); + this.creator = this.client.users._add(data.creator); /** * The time of when this template was created at @@ -130,7 +130,7 @@ class GuildTemplate extends Base { client.incrementMaxListeners(); client.on(Events.GUILD_CREATE, handleGuild); - const timeout = client.setTimeout(() => resolveGuild(client.guilds.add(data)), 10000); + const timeout = client.setTimeout(() => resolveGuild(client.guilds._add(data)), 10000); }); } diff --git a/src/structures/Integration.js b/src/structures/Integration.js index 74ef3bb73..4adb0dc9e 100644 --- a/src/structures/Integration.js +++ b/src/structures/Integration.js @@ -64,7 +64,7 @@ class Integration extends Base { * The user for this integration * @type {?User} */ - this.user = this.client.users.add(data.user); + this.user = this.client.users._add(data.user); } else { this.user = null; } diff --git a/src/structures/IntegrationApplication.js b/src/structures/IntegrationApplication.js index 93dc88f52..d9a6d3946 100644 --- a/src/structures/IntegrationApplication.js +++ b/src/structures/IntegrationApplication.js @@ -14,7 +14,7 @@ class IntegrationApplication extends Application { * The bot user for this application * @type {?User} */ - this.bot = data.bot ? this.client.users.add(data.bot) : this.bot ?? null; + this.bot = data.bot ? this.client.users._add(data.bot) : this.bot ?? null; /** * The url of the application's terms of service diff --git a/src/structures/Interaction.js b/src/structures/Interaction.js index 56f301677..47e7502fa 100644 --- a/src/structures/Interaction.js +++ b/src/structures/Interaction.js @@ -54,13 +54,13 @@ class Interaction extends Base { * The user which sent this interaction * @type {User} */ - this.user = this.client.users.add(data.user ?? data.member.user); + this.user = this.client.users._add(data.user ?? data.member.user); /** * If this interaction was sent in a guild, the member which sent it * @type {?(GuildMember|APIGuildMember)} */ - this.member = data.member ? this.guild?.members.add(data.member) ?? data.member : null; + this.member = data.member ? this.guild?.members._add(data.member) ?? data.member : null; /** * The version diff --git a/src/structures/Invite.js b/src/structures/Invite.js index 4aac077ae..f325eceef 100644 --- a/src/structures/Invite.js +++ b/src/structures/Invite.js @@ -76,13 +76,13 @@ class Invite extends Base { * The user who created this invite * @type {?User} */ - this.inviter = data.inviter ? this.client.users.add(data.inviter) : null; + this.inviter = data.inviter ? this.client.users._add(data.inviter) : null; /** * The user whose stream to display for this voice channel stream invite * @type {?User} */ - this.targetUser = data.target_user ? this.client.users.add(data.target_user) : null; + this.targetUser = data.target_user ? this.client.users._add(data.target_user) : null; /** * The embedded application to open for this voice channel embedded application invite @@ -109,7 +109,7 @@ class Invite extends Base { * The channel the invite is for * @type {Channel} */ - this.channel = this.client.channels.add(data.channel, this.guild, false); + this.channel = this.client.channels._add(data.channel, this.guild, false); /** * The timestamp the invite was created at diff --git a/src/structures/InviteStageInstance.js b/src/structures/InviteStageInstance.js index bb94ca6e1..6787e6fee 100644 --- a/src/structures/InviteStageInstance.js +++ b/src/structures/InviteStageInstance.js @@ -53,7 +53,7 @@ class InviteStageInstance extends Base { this.members.clear(); for (const rawMember of data.members) { - const member = this.guild.members.add(rawMember); + const member = this.guild.members._add(rawMember); this.members.set(member.id, member); } } diff --git a/src/structures/Message.js b/src/structures/Message.js index 4ba63f9da..cdd8b7cd6 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -86,7 +86,7 @@ class Message extends Base { * The author of the message * @type {?User} */ - this.author = this.client.users.add(data.author, !data.webhook_id); + this.author = this.client.users._add(data.author, !data.webhook_id); } else if (!this.author) { this.author = null; } @@ -106,7 +106,7 @@ class Message extends Base { * The thread started by this message * @type {?ThreadChannel} */ - this.thread = this.client.channels.add(data.thread); + this.thread = this.client.channels._add(data.thread); } else if (!this.thread) { this.thread = null; } @@ -182,7 +182,7 @@ class Message extends Base { this.reactions = new ReactionManager(this); if (data.reactions?.length > 0) { for (const reaction of data.reactions) { - this.reactions.add(reaction); + this.reactions._add(reaction); } } @@ -231,7 +231,7 @@ class Message extends Base { if (this.member && data.member) { this.member._patch(data.member); } else if (data.member && this.guild && this.author) { - this.guild.members.add(Object.assign(data.member, { user: this.author })); + this.guild.members._add(Object.assign(data.member, { user: this.author })); } /** @@ -261,7 +261,7 @@ class Message extends Base { : null; if (data.referenced_message) { - this.channel.messages.add(data.referenced_message); + this.channel.messages._add(data.referenced_message); } /** @@ -282,7 +282,7 @@ class Message extends Base { id: data.interaction.id, type: InteractionTypes[data.interaction.type], commandName: data.interaction.name, - user: this.client.users.add(data.interaction.user), + user: this.client.users._add(data.interaction.user), }; } else if (!this.interaction) { this.interaction = null; @@ -311,7 +311,7 @@ class Message extends Base { if ('content' in data) this.content = data.content; if ('pinned' in data) this.pinned = data.pinned; if ('tts' in data) this.tts = data.tts; - if ('thread' in data) this.thread = this.client.channels.add(data.thread); + if ('thread' in data) this.thread = this.client.channels._add(data.thread); if ('attachments' in data) { this.attachments = new Collection(); diff --git a/src/structures/MessageComponentInteraction.js b/src/structures/MessageComponentInteraction.js index 6e4c5c2b4..65c7f2730 100644 --- a/src/structures/MessageComponentInteraction.js +++ b/src/structures/MessageComponentInteraction.js @@ -18,7 +18,7 @@ class MessageComponentInteraction extends Interaction { * The message to which the component was attached * @type {Message|APIMessage} */ - this.message = this.channel?.messages.add(data.message) ?? data.message; + this.message = this.channel?.messages._add(data.message) ?? data.message; /** * The custom id of the component which was interacted with diff --git a/src/structures/MessageMentions.js b/src/structures/MessageMentions.js index 472bf3a97..957437d19 100644 --- a/src/structures/MessageMentions.js +++ b/src/structures/MessageMentions.js @@ -49,9 +49,9 @@ class MessageMentions { this.users = new Collection(); for (const mention of users) { if (mention.member && message.guild) { - message.guild.members.add(Object.assign(mention.member, { user: mention })); + message.guild.members._add(Object.assign(mention.member, { user: mention })); } - const user = message.client.users.add(mention); + const user = message.client.users._add(mention); this.users.set(user.id, user); } } @@ -130,7 +130,7 @@ class MessageMentions { * The author of the message that this message is a reply to * @type {?User} */ - this.repliedUser = repliedUser ? this.client.users.add(repliedUser) : null; + this.repliedUser = repliedUser ? this.client.users._add(repliedUser) : null; } /** diff --git a/src/structures/TeamMember.js b/src/structures/TeamMember.js index 4a035978a..52753fa66 100644 --- a/src/structures/TeamMember.js +++ b/src/structures/TeamMember.js @@ -37,7 +37,7 @@ class TeamMember extends Base { * The user for this Team Member * @type {User} */ - this.user = this.client.users.add(data.user); + this.user = this.client.users._add(data.user); } /** diff --git a/src/structures/TextChannel.js b/src/structures/TextChannel.js index 490d523db..f6b4a3fd5 100644 --- a/src/structures/TextChannel.js +++ b/src/structures/TextChannel.js @@ -90,7 +90,7 @@ class TextChannel extends GuildChannel { } if ('messages' in data) { - for (const message of data.messages) this.messages.add(message); + for (const message of data.messages) this.messages._add(message); } } diff --git a/src/structures/ThreadChannel.js b/src/structures/ThreadChannel.js index 83dca99de..b98a5525b 100644 --- a/src/structures/ThreadChannel.js +++ b/src/structures/ThreadChannel.js @@ -150,7 +150,7 @@ class ThreadChannel extends Channel { } if (data.member && this.client.user) this.members._add({ user_id: this.client.user.id, ...data.member }); - if (data.messages) for (const message of data.messages) this.messages.add(message); + if (data.messages) for (const message of data.messages) this.messages._add(message); } /** diff --git a/src/structures/User.js b/src/structures/User.js index 66c39ad5d..62d5dbad4 100644 --- a/src/structures/User.js +++ b/src/structures/User.js @@ -212,7 +212,7 @@ class User extends Base { recipient_id: this.id, }, }); - return this.client.channels.add(data); + return this.client.channels._add(data); } /** @@ -223,7 +223,7 @@ class User extends Base { const { dmChannel } = this; if (!dmChannel) throw new Error('USER_NO_DMCHANNEL'); await this.client.api.channels(dmChannel.id).delete(); - this.client.channels.remove(dmChannel.id); + this.client.channels._remove(dmChannel.id); return dmChannel; } diff --git a/src/structures/Webhook.js b/src/structures/Webhook.js index d4b21f1a0..80ad0e5ee 100644 --- a/src/structures/Webhook.js +++ b/src/structures/Webhook.js @@ -70,14 +70,14 @@ class Webhook { * The owner of the webhook * @type {?(User|APIUser)} */ - this.owner = data.user ? this.client.users?.add(data.user) ?? data.user : null; + this.owner = data.user ? this.client.users?._add(data.user) ?? data.user : null; /** * The source guild of the webhook * @type {?(Guild|APIGuild)} */ this.sourceGuild = data.source_guild - ? this.client.guilds?.add(data.source_guild, false) ?? data.source_guild + ? this.client.guilds?._add(data.source_guild, false) ?? data.source_guild : null; /** @@ -175,7 +175,7 @@ class Webhook { query: { thread_id: messagePayload.options.threadId, wait: true }, auth: false, }) - .then(d => this.client.channels?.cache.get(d.channel_id)?.messages.add(d, false) ?? d); + .then(d => this.client.channels?.cache.get(d.channel_id)?.messages._add(d, false) ?? d); } /** @@ -250,7 +250,7 @@ class Webhook { if (!this.token) throw new Error('WEBHOOK_TOKEN_UNAVAILABLE'); const data = await this.client.api.webhooks(this.id, this.token).messages(message).get(); - return this.client.channels?.cache.get(data.channel_id)?.messages.add(data, cache) ?? data; + return this.client.channels?.cache.get(data.channel_id)?.messages._add(data, cache) ?? data; } /** @@ -279,7 +279,7 @@ class Webhook { if (!messageManager) return d; const existing = messageManager.cache.get(d.id); - if (!existing) return messageManager.add(d); + if (!existing) return messageManager._add(d); const clone = existing._clone(); clone._patch(d); diff --git a/test/tester2000.js b/test/tester2000.js index 3d52b81fb..c47b73fdf 100644 --- a/test/tester2000.js +++ b/test/tester2000.js @@ -7,7 +7,8 @@ const { Client, Options, Intents, Formatters } = require('../src'); const log = (...args) => console.log(process.uptime().toFixed(3), ...args); const client = new Client({ - intents: Intents.ALL, + // 😏 + intents: Object.values(Intents.FLAGS).reduce((acc, p) => acc | p, 0), makeCache: Options.cacheWithLimits({ MessageManager: 10, PresenceManager: 10, diff --git a/typings/index.d.ts b/typings/index.d.ts index 181f23ef1..a6148e948 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -2054,7 +2054,7 @@ export abstract class DataManager extends BaseManager { export abstract class CachedManager extends DataManager { public constructor(client: Client, holds: Constructable); - public add(data: unknown, cache?: boolean, { id, extras }?: { id: K; extras: unknown[] }): Holds; + private _add(data: unknown, cache?: boolean, { id, extras }?: { id: K; extras: unknown[] }): Holds; } export class ApplicationCommandManager< @@ -2373,12 +2373,9 @@ export class ThreadManager extends CachedManager; } -export interface ThreadMemberManager - extends Omit, 'add'> {} -export class ThreadMemberManager { +export class ThreadMemberManager extends CachedManager { public constructor(thread: ThreadChannel, iterable?: Iterable); public thread: ThreadChannel; - public _add(data: unknown, cache?: boolean): ThreadMember; public add(member: UserResolvable | '@me', reason?: string): Promise; public fetch(cache?: boolean): Promise>; public remove(id: Snowflake | '@me', reason?: string): Promise;