diff --git a/packages/discord.js/src/client/Client.js b/packages/discord.js/src/client/Client.js index b6d02f738a76..92b23cbf6fe4 100644 --- a/packages/discord.js/src/client/Client.js +++ b/packages/discord.js/src/client/Client.js @@ -369,7 +369,7 @@ class Client extends BaseClient { */ async fetchStickerPacks() { const data = await this.rest.get(Routes.stickerPacks()); - return new Collection(data.sticker_packs.map(p => [p.id, new StickerPack(this, p)])); + return new Collection(data.sticker_packs.map(stickerPack => [stickerPack.id, new StickerPack(this, stickerPack)])); } /** diff --git a/packages/discord.js/src/client/websocket/WebSocketManager.js b/packages/discord.js/src/client/websocket/WebSocketManager.js index f62610b78ffb..3ec0e7004dd5 100644 --- a/packages/discord.js/src/client/websocket/WebSocketManager.js +++ b/packages/discord.js/src/client/websocket/WebSocketManager.js @@ -364,7 +364,7 @@ class WebSocketManager extends EventEmitter { */ checkShardsReady() { if (this.status === Status.Ready) return; - if (this.shards.size !== this.totalShards || this.shards.some(s => s.status !== Status.Ready)) { + if (this.shards.size !== this.totalShards || this.shards.some(shard => shard.status !== Status.Ready)) { return; } diff --git a/packages/discord.js/src/client/websocket/WebSocketShard.js b/packages/discord.js/src/client/websocket/WebSocketShard.js index 05bc2253d295..c96c97cdda9d 100644 --- a/packages/discord.js/src/client/websocket/WebSocketShard.js +++ b/packages/discord.js/src/client/websocket/WebSocketShard.js @@ -140,7 +140,7 @@ class WebSocketShard extends EventEmitter { */ this.emit(WebSocketShardEvents.Ready); - this.expectedGuilds = new Set(packet.guilds.map(d => d.id)); + this.expectedGuilds = new Set(packet.guilds.map(guild => guild.id)); this.status = Status.WaitingForGuilds; } diff --git a/packages/discord.js/src/managers/ApplicationCommandManager.js b/packages/discord.js/src/managers/ApplicationCommandManager.js index 983a4b13d497..884ad9258cde 100644 --- a/packages/discord.js/src/managers/ApplicationCommandManager.js +++ b/packages/discord.js/src/managers/ApplicationCommandManager.js @@ -169,9 +169,12 @@ class ApplicationCommandManager extends CachedManager { */ async set(commands, guildId) { const data = await this.client.rest.put(this.commandPath({ guildId }), { - body: commands.map(c => this.constructor.transformCommand(c)), + body: commands.map(command => this.constructor.transformCommand(command)), }); - return data.reduce((coll, command) => coll.set(command.id, this._add(command, true, guildId)), new Collection()); + return data.reduce( + (collection, command) => collection.set(command.id, this._add(command, true, guildId)), + new Collection(), + ); } /** @@ -253,7 +256,7 @@ class ApplicationCommandManager extends CachedManager { nsfw: command.nsfw, description_localizations: command.descriptionLocalizations ?? command.description_localizations, type: command.type, - options: command.options?.map(o => ApplicationCommand.transformOption(o)), + options: command.options?.map(option => ApplicationCommand.transformOption(option)), default_member_permissions, dm_permission: command.dmPermission ?? command.dm_permission, }; diff --git a/packages/discord.js/src/managers/ApplicationCommandPermissionsManager.js b/packages/discord.js/src/managers/ApplicationCommandPermissionsManager.js index 2f7279ae3cf4..1851b3017021 100644 --- a/packages/discord.js/src/managers/ApplicationCommandPermissionsManager.js +++ b/packages/discord.js/src/managers/ApplicationCommandPermissionsManager.js @@ -210,17 +210,17 @@ class ApplicationCommandPermissionsManager extends BaseManager { ); } - let existing = []; + let existingPermissions = []; try { - existing = await this.fetch({ guild: guildId, command: commandId }); + existingPermissions = await this.fetch({ guild: guildId, command: commandId }); } catch (error) { if (error.code !== RESTJSONErrorCodes.UnknownApplicationCommandPermissions) throw error; } const newPermissions = permissions.slice(); - for (const perm of existing) { - if (!newPermissions.some(x => x.id === perm.id)) { - newPermissions.push(perm); + for (const existingPermission of existingPermissions) { + if (!newPermissions.some(newPermission => newPermission.id === existingPermission.id)) { + newPermissions.push(existingPermission); } } diff --git a/packages/discord.js/src/managers/CategoryChannelChildManager.js b/packages/discord.js/src/managers/CategoryChannelChildManager.js index dd0f67261512..c7e21c478089 100644 --- a/packages/discord.js/src/managers/CategoryChannelChildManager.js +++ b/packages/discord.js/src/managers/CategoryChannelChildManager.js @@ -23,7 +23,7 @@ class CategoryChannelChildManager extends DataManager { * @readonly */ get cache() { - return this.guild.channels.cache.filter(c => c.parentId === this.channel.id); + return this.guild.channels.cache.filter(channel => channel.parentId === this.channel.id); } /** diff --git a/packages/discord.js/src/managers/GuildChannelManager.js b/packages/discord.js/src/managers/GuildChannelManager.js index 376965c250d1..535d1034ca19 100644 --- a/packages/discord.js/src/managers/GuildChannelManager.js +++ b/packages/discord.js/src/managers/GuildChannelManager.js @@ -166,7 +166,7 @@ class GuildChannelManager extends CachedManager { reason, }) { parent &&= this.client.channels.resolveId(parent); - permissionOverwrites &&= permissionOverwrites.map(o => PermissionOverwrites.resolve(o, this.guild)); + permissionOverwrites &&= permissionOverwrites.map(overwrite => PermissionOverwrites.resolve(overwrite, this.guild)); const data = await this.client.rest.post(Routes.guildChannels(this.guild.id), { body: { @@ -281,19 +281,21 @@ class GuildChannelManager extends CachedManager { await this.setPosition(channel, options.position, { position: options.position, reason: options.reason }); } - let permission_overwrites = options.permissionOverwrites?.map(o => PermissionOverwrites.resolve(o, this.guild)); + let permission_overwrites = options.permissionOverwrites?.map(overwrite => + PermissionOverwrites.resolve(overwrite, this.guild), + ); if (options.lockPermissions) { if (parent) { const newParent = this.guild.channels.resolve(parent); if (newParent?.type === ChannelType.GuildCategory) { - permission_overwrites = newParent.permissionOverwrites.cache.map(o => - PermissionOverwrites.resolve(o, this.guild), + permission_overwrites = newParent.permissionOverwrites.cache.map(overwrite => + PermissionOverwrites.resolve(overwrite, this.guild), ); } } else if (channel.parent) { - permission_overwrites = channel.parent.permissionOverwrites.cache.map(o => - PermissionOverwrites.resolve(o, this.guild), + permission_overwrites = channel.parent.permissionOverwrites.cache.map(overwrite => + PermissionOverwrites.resolve(overwrite, this.guild), ); } } @@ -438,11 +440,11 @@ class GuildChannelManager extends CachedManager { * .catch(console.error); */ async setPositions(channelPositions) { - channelPositions = channelPositions.map(r => ({ - id: this.client.channels.resolveId(r.channel), - position: r.position, - lock_permissions: r.lockPermissions, - parent_id: r.parent !== undefined ? this.resolveId(r.parent) : undefined, + channelPositions = channelPositions.map(channelPosition => ({ + id: this.client.channels.resolveId(channelPosition.channel), + position: channelPosition.position, + lock_permissions: channelPosition.lockPermissions, + parent_id: channelPosition.parent !== undefined ? this.resolveId(channelPosition.parent) : undefined, })); await this.client.rest.patch(Routes.guildChannels(this.guild.id), { body: channelPositions }); diff --git a/packages/discord.js/src/managers/GuildEmojiManager.js b/packages/discord.js/src/managers/GuildEmojiManager.js index 61f5050fac99..231c5da47663 100644 --- a/packages/discord.js/src/managers/GuildEmojiManager.js +++ b/packages/discord.js/src/managers/GuildEmojiManager.js @@ -130,7 +130,7 @@ class GuildEmojiManager extends BaseGuildEmojiManager { async edit(emoji, options) { const id = this.resolveId(emoji); if (!id) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'emoji', 'EmojiResolvable', true); - const roles = options.roles?.map(r => this.guild.roles.resolveId(r)); + const roles = options.roles?.map(role => this.guild.roles.resolveId(role)); const newData = await this.client.rest.patch(Routes.guildEmoji(this.guild.id, id), { body: { name: options.name, diff --git a/packages/discord.js/src/managers/MessageManager.js b/packages/discord.js/src/managers/MessageManager.js index d428324e2a07..7494b4dc4109 100644 --- a/packages/discord.js/src/managers/MessageManager.js +++ b/packages/discord.js/src/managers/MessageManager.js @@ -86,7 +86,8 @@ class MessageManager extends CachedManager { * @example * // Fetch messages and filter by a user id * channel.messages.fetch() - * .then(messages => console.log(`${messages.filter(m => m.author.id === '84484653687267328').size} messages`)) + * .then(messages => console.log(`${messages.filter(message => + * message.author.id === '84484653687267328').size} messages`)) * .catch(console.error); */ fetch(options) { diff --git a/packages/discord.js/src/managers/RoleManager.js b/packages/discord.js/src/managers/RoleManager.js index e0c4ed7d97c7..288bd8b35742 100644 --- a/packages/discord.js/src/managers/RoleManager.js +++ b/packages/discord.js/src/managers/RoleManager.js @@ -280,9 +280,9 @@ class RoleManager extends CachedManager { */ async setPositions(rolePositions) { // Make sure rolePositions are prepared for API - rolePositions = rolePositions.map(o => ({ - id: this.resolveId(o.role), - position: o.position, + rolePositions = rolePositions.map(rolePosition => ({ + id: this.resolveId(rolePosition.role), + position: rolePosition.position, })); // Call the API to update role positions diff --git a/packages/discord.js/src/managers/UserManager.js b/packages/discord.js/src/managers/UserManager.js index 24478f6386b4..18fdbfe46852 100644 --- a/packages/discord.js/src/managers/UserManager.js +++ b/packages/discord.js/src/managers/UserManager.js @@ -40,7 +40,10 @@ class UserManager extends CachedManager { * @private */ dmChannel(userId) { - return this.client.channels.cache.find(c => c.type === ChannelType.DM && c.recipientId === userId) ?? null; + return ( + this.client.channels.cache.find(channel => channel.type === ChannelType.DM && channel.recipientId === userId) ?? + null + ); } /** diff --git a/packages/discord.js/src/structures/ActionRow.js b/packages/discord.js/src/structures/ActionRow.js index 3f39691b1101..0f14d971ec27 100644 --- a/packages/discord.js/src/structures/ActionRow.js +++ b/packages/discord.js/src/structures/ActionRow.js @@ -18,7 +18,7 @@ class ActionRow extends Component { * @type {Component[]} * @readonly */ - this.components = components.map(c => createComponent(c)); + this.components = components.map(component => createComponent(component)); } /** @@ -39,7 +39,7 @@ class ActionRow extends Component { * @returns {APIActionRowComponent} */ toJSON() { - return { ...this.data, components: this.components.map(c => c.toJSON()) }; + return { ...this.data, components: this.components.map(component => component.toJSON()) }; } } diff --git a/packages/discord.js/src/structures/ActionRowBuilder.js b/packages/discord.js/src/structures/ActionRowBuilder.js index 962a378c2a41..2911d60a4799 100644 --- a/packages/discord.js/src/structures/ActionRowBuilder.js +++ b/packages/discord.js/src/structures/ActionRowBuilder.js @@ -13,7 +13,7 @@ class ActionRowBuilder extends BuildersActionRow { constructor({ components, ...data } = {}) { super({ ...toSnakeCase(data), - components: components?.map(c => createComponentBuilder(c)), + components: components?.map(component => createComponentBuilder(component)), }); } diff --git a/packages/discord.js/src/structures/ApplicationCommand.js b/packages/discord.js/src/structures/ApplicationCommand.js index bd87281c11f5..23647cc70101 100644 --- a/packages/discord.js/src/structures/ApplicationCommand.js +++ b/packages/discord.js/src/structures/ApplicationCommand.js @@ -123,7 +123,7 @@ class ApplicationCommand extends Base { * The options of this command * @type {ApplicationCommandOption[]} */ - this.options = data.options.map(o => this.constructor.transformOption(o, true)); + this.options = data.options.map(option => this.constructor.transformOption(option, true)); } else { this.options ??= []; } @@ -577,7 +577,7 @@ class ApplicationCommand extends Base { [nameLocalizationsKey]: choice.nameLocalizations ?? choice.name_localizations, value: choice.value, })), - options: option.options?.map(o => this.transformOption(o, received)), + options: option.options?.map(opt => this.transformOption(opt, received)), [channelTypesKey]: option.channelTypes ?? option.channel_types, [minValueKey]: option.minValue ?? option.min_value, [maxValueKey]: option.maxValue ?? option.max_value, diff --git a/packages/discord.js/src/structures/ChatInputCommandInteraction.js b/packages/discord.js/src/structures/ChatInputCommandInteraction.js index 35175e49c470..4c4daf832a8b 100644 --- a/packages/discord.js/src/structures/ChatInputCommandInteraction.js +++ b/packages/discord.js/src/structures/ChatInputCommandInteraction.js @@ -32,7 +32,7 @@ class ChatInputCommandInteraction extends CommandInteraction { this.commandName, this.options._group, this.options._subcommand, - ...this.options._hoistedOptions.map(o => `${o.name}:${o.value}`), + ...this.options._hoistedOptions.map(option => `${option.name}:${option.value}`), ]; return `/${properties.filter(Boolean).join(' ')}`; } diff --git a/packages/discord.js/src/structures/ClientPresence.js b/packages/discord.js/src/structures/ClientPresence.js index 6dd72ee94817..6674d9b83f91 100644 --- a/packages/discord.js/src/structures/ClientPresence.js +++ b/packages/discord.js/src/structures/ClientPresence.js @@ -68,11 +68,11 @@ class ClientPresence extends Presence { } } else if (!activities && (status || afk || since) && this.activities.length) { data.activities.push( - ...this.activities.map(a => ({ - name: a.name, - state: a.state ?? undefined, - type: a.type, - url: a.url ?? undefined, + ...this.activities.map(activity => ({ + name: activity.name, + state: activity.state ?? undefined, + type: activity.type, + url: activity.url ?? undefined, })), ); } diff --git a/packages/discord.js/src/structures/Guild.js b/packages/discord.js/src/structures/Guild.js index 329026e126c2..b4692ef9ae8a 100644 --- a/packages/discord.js/src/structures/Guild.js +++ b/packages/discord.js/src/structures/Guild.js @@ -1263,7 +1263,7 @@ class Guild extends AnonymousGuild { * @example * // Delete a guild * guild.delete() - * .then(g => console.log(`Deleted the guild ${g}`)) + * .then(guild => console.log(`Deleted the guild ${guild}`)) * .catch(console.error); */ async delete() { @@ -1365,7 +1365,9 @@ class Guild extends AnonymousGuild { const channelIsCategory = channel.type === ChannelType.GuildCategory; const types = getSortableGroupTypes(channel.type); return discordSort( - this.channels.cache.filter(c => types.includes(c.type) && (channelIsCategory || c.parentId === channel.parentId)), + this.channels.cache.filter( + ({ parentId, type }) => types.includes(type) && (channelIsCategory || parentId === channel.parentId), + ), ); } } diff --git a/packages/discord.js/src/structures/GuildAuditLogsEntry.js b/packages/discord.js/src/structures/GuildAuditLogsEntry.js index 9ed2626555d7..bed82a510bb1 100644 --- a/packages/discord.js/src/structures/GuildAuditLogsEntry.js +++ b/packages/discord.js/src/structures/GuildAuditLogsEntry.js @@ -164,7 +164,8 @@ class GuildAuditLogsEntry { * Specific property changes * @type {AuditLogChange[]} */ - this.changes = data.changes?.map(c => ({ key: c.key, old: c.old_value, new: c.new_value })) ?? []; + this.changes = + data.changes?.map(change => ({ key: change.key, old: change.old_value, new: change.new_value })) ?? []; /** * The entry's id @@ -302,10 +303,11 @@ class GuildAuditLogsEntry { }), ); } else if (targetType === Targets.Invite) { - let change = this.changes.find(c => c.key === 'code'); - change = change.new ?? change.old; + const inviteChange = this.changes.find(({ key }) => key === 'code'); - this.target = guild.invites.cache.get(change) ?? new Invite(guild.client, changesReduce(this.changes, { guild })); + this.target = + guild.invites.cache.get(inviteChange.new ?? inviteChange.old) ?? + new Invite(guild.client, changesReduce(this.changes, { guild })); } else if (targetType === Targets.Message) { // Discord sends a channel id for the MessageBulkDelete action type. this.target = diff --git a/packages/discord.js/src/structures/GuildChannel.js b/packages/discord.js/src/structures/GuildChannel.js index dee674d5b7ce..a25434a48300 100644 --- a/packages/discord.js/src/structures/GuildChannel.js +++ b/packages/discord.js/src/structures/GuildChannel.js @@ -279,7 +279,9 @@ class GuildChannel extends BaseChannel { * @readonly */ get members() { - return this.guild.members.cache.filter(m => this.permissionsFor(m).has(PermissionFlagsBits.ViewChannel, false)); + return this.guild.members.cache.filter(member => + this.permissionsFor(member).has(PermissionFlagsBits.ViewChannel, false), + ); } /** diff --git a/packages/discord.js/src/structures/GuildEmoji.js b/packages/discord.js/src/structures/GuildEmoji.js index 0035a36e0197..a9f781a5360e 100644 --- a/packages/discord.js/src/structures/GuildEmoji.js +++ b/packages/discord.js/src/structures/GuildEmoji.js @@ -91,7 +91,7 @@ class GuildEmoji extends BaseGuildEmoji { * @example * // Edit an emoji * emoji.edit({ name: 'newemoji' }) - * .then(e => console.log(`Edited emoji ${e}`)) + * .then(emoji => console.log(`Edited emoji ${emoji}`)) * .catch(console.error); */ edit(options) { diff --git a/packages/discord.js/src/structures/Message.js b/packages/discord.js/src/structures/Message.js index c82c177ab146..75b327dc5cce 100644 --- a/packages/discord.js/src/structures/Message.js +++ b/packages/discord.js/src/structures/Message.js @@ -141,7 +141,7 @@ class Message extends Base { * in a guild for messages that do not mention the client. * @type {Embed[]} */ - this.embeds = data.embeds.map(e => new Embed(e)); + this.embeds = data.embeds.map(embed => new Embed(embed)); } else { this.embeds = this.embeds?.slice() ?? []; } @@ -153,7 +153,7 @@ class Message extends Base { * in a guild for messages that do not mention the client. * @type {ActionRow[]} */ - this.components = data.components.map(c => createComponent(c)); + this.components = data.components.map(component => createComponent(component)); } else { this.components = this.components?.slice() ?? []; } @@ -181,7 +181,7 @@ class Message extends Base { * @type {Collection} */ this.stickers = new Collection( - (data.sticker_items ?? data.stickers)?.map(s => [s.id, new Sticker(this.client, s)]), + (data.sticker_items ?? data.stickers)?.map(sticker => [sticker.id, new Sticker(this.client, sticker)]), ); } else { this.stickers = new Collection(this.stickers); diff --git a/packages/discord.js/src/structures/MessageMentions.js b/packages/discord.js/src/structures/MessageMentions.js index a07e77fb5d70..dd514db8536d 100644 --- a/packages/discord.js/src/structures/MessageMentions.js +++ b/packages/discord.js/src/structures/MessageMentions.js @@ -167,12 +167,12 @@ class MessageMentions { this.crosspostedChannels = new Collection(crosspostedChannels); } else { this.crosspostedChannels = new Collection(); - for (const d of crosspostedChannels) { - this.crosspostedChannels.set(d.id, { - channelId: d.id, - guildId: d.guild_id, - type: d.type, - name: d.name, + for (const crosspostedChannel of crosspostedChannels) { + this.crosspostedChannels.set(crosspostedChannel.id, { + channelId: crosspostedChannel.id, + guildId: crosspostedChannel.guild_id, + type: crosspostedChannel.type, + name: crosspostedChannel.name, }); } } diff --git a/packages/discord.js/src/structures/MessagePayload.js b/packages/discord.js/src/structures/MessagePayload.js index e23730906c8e..b013bd0bd530 100644 --- a/packages/discord.js/src/structures/MessagePayload.js +++ b/packages/discord.js/src/structures/MessagePayload.js @@ -133,7 +133,9 @@ class MessagePayload { } } - const components = this.options.components?.map(c => (isJSONEncodable(c) ? c : new ActionRowBuilder(c)).toJSON()); + const components = this.options.components?.map(component => + (isJSONEncodable(component) ? component : new ActionRowBuilder(component)).toJSON(), + ); let username; let avatarURL; diff --git a/packages/discord.js/src/structures/ModalBuilder.js b/packages/discord.js/src/structures/ModalBuilder.js index 535b4a52a51b..fa45b847897e 100644 --- a/packages/discord.js/src/structures/ModalBuilder.js +++ b/packages/discord.js/src/structures/ModalBuilder.js @@ -12,7 +12,9 @@ class ModalBuilder extends BuildersModal { constructor({ components, ...data } = {}) { super({ ...toSnakeCase(data), - components: components?.map(c => (c instanceof ComponentBuilder ? c : toSnakeCase(c))), + components: components?.map(component => + component instanceof ComponentBuilder ? component : toSnakeCase(component), + ), }); } diff --git a/packages/discord.js/src/structures/ModalSubmitFields.js b/packages/discord.js/src/structures/ModalSubmitFields.js index 8e67b21d2e6f..a2f691f3ae9c 100644 --- a/packages/discord.js/src/structures/ModalSubmitFields.js +++ b/packages/discord.js/src/structures/ModalSubmitFields.js @@ -20,7 +20,7 @@ class ModalSubmitFields { * @type {Collection} */ this.fields = components.reduce((accumulator, next) => { - next.components.forEach(c => accumulator.set(c.customId, c)); + next.components.forEach(component => accumulator.set(component.customId, component)); return accumulator; }, new Collection()); } diff --git a/packages/discord.js/src/structures/ModalSubmitInteraction.js b/packages/discord.js/src/structures/ModalSubmitInteraction.js index 8f0ccf16c127..559807bfa078 100644 --- a/packages/discord.js/src/structures/ModalSubmitInteraction.js +++ b/packages/discord.js/src/structures/ModalSubmitInteraction.js @@ -49,7 +49,7 @@ class ModalSubmitInteraction extends BaseInteraction { * The components within the modal * @type {ActionRowModalData[]} */ - this.components = data.data.components?.map(c => ModalSubmitInteraction.transformComponent(c)); + this.components = data.data.components?.map(component => ModalSubmitInteraction.transformComponent(component)); /** * The fields within the modal @@ -89,7 +89,10 @@ class ModalSubmitInteraction extends BaseInteraction { */ static transformComponent(rawComponent) { return rawComponent.components - ? { type: rawComponent.type, components: rawComponent.components.map(c => this.transformComponent(c)) } + ? { + type: rawComponent.type, + components: rawComponent.components.map(component => this.transformComponent(component)), + } : { value: rawComponent.value, type: rawComponent.type, diff --git a/packages/discord.js/src/structures/ReactionCollector.js b/packages/discord.js/src/structures/ReactionCollector.js index 924b33bf1811..e6e46241dc7c 100644 --- a/packages/discord.js/src/structures/ReactionCollector.js +++ b/packages/discord.js/src/structures/ReactionCollector.js @@ -94,9 +94,9 @@ class ReactionCollector extends Collector { this.users.set(user.id, user); }); - this.on('remove', (reaction, user) => { + this.on('remove', (_reaction, user) => { this.total--; - if (!this.collected.some(r => r.users.cache.has(user.id))) this.users.delete(user.id); + if (!this.collected.some(reaction => reaction.users.cache.has(user.id))) this.users.delete(user.id); }); } diff --git a/packages/discord.js/src/structures/Role.js b/packages/discord.js/src/structures/Role.js index 53e413d889e0..37daaa3f287f 100644 --- a/packages/discord.js/src/structures/Role.js +++ b/packages/discord.js/src/structures/Role.js @@ -180,7 +180,7 @@ class Role extends Base { get members() { return this.id === this.guild.id ? this.guild.members.cache.clone() - : this.guild.members.cache.filter(m => m._roles.includes(this.id)); + : this.guild.members.cache.filter(member => member._roles.includes(this.id)); } /** diff --git a/packages/discord.js/src/structures/Sticker.js b/packages/discord.js/src/structures/Sticker.js index 4c7bb681a373..7391f18e7903 100644 --- a/packages/discord.js/src/structures/Sticker.js +++ b/packages/discord.js/src/structures/Sticker.js @@ -212,7 +212,7 @@ class Sticker extends Base { * @example * // Update the name of a sticker * sticker.edit({ name: 'new name' }) - * .then(s => console.log(`Updated the name of the sticker to ${s.name}`)) + * .then(sticker => console.log(`Updated the name of the sticker to ${sticker.name}`)) * .catch(console.error); */ edit(options) { @@ -226,7 +226,7 @@ class Sticker extends Base { * @example * // Delete a message * sticker.delete() - * .then(s => console.log(`Deleted sticker ${s.name}`)) + * .then(sticker => console.log(`Deleted sticker ${sticker.name}`)) * .catch(console.error); */ async delete(reason) { diff --git a/packages/discord.js/src/structures/StickerPack.js b/packages/discord.js/src/structures/StickerPack.js index 7e599b764361..45226b3d6b96 100644 --- a/packages/discord.js/src/structures/StickerPack.js +++ b/packages/discord.js/src/structures/StickerPack.js @@ -22,7 +22,7 @@ class StickerPack extends Base { * The stickers in the pack * @type {Collection} */ - this.stickers = new Collection(pack.stickers.map(s => [s.id, new Sticker(client, s)])); + this.stickers = new Collection(pack.stickers.map(sticker => [sticker.id, new Sticker(client, sticker)])); /** * The name of the sticker pack diff --git a/packages/discord.js/src/structures/interfaces/TextBasedChannel.js b/packages/discord.js/src/structures/interfaces/TextBasedChannel.js index f3bfa8bfd567..7d7649736899 100644 --- a/packages/discord.js/src/structures/interfaces/TextBasedChannel.js +++ b/packages/discord.js/src/structures/interfaces/TextBasedChannel.js @@ -174,9 +174,9 @@ class TextBasedChannel { * @returns {MessageCollector} * @example * // Create a message collector - * const filter = m => m.content.includes('discord'); + * const filter = message => message.content.includes('discord'); * const collector = channel.createMessageCollector({ filter, time: 15_000 }); - * collector.on('collect', m => console.log(`Collected ${m.content}`)); + * collector.on('collect', message => console.log(`Collected ${message.content}`)); * collector.on('end', collected => console.log(`Collected ${collected.size} items`)); */ createMessageCollector(options = {}) { @@ -223,7 +223,7 @@ class TextBasedChannel { * // Create a button interaction collector * const filter = (interaction) => interaction.customId === 'button' && interaction.user.id === 'someId'; * const collector = channel.createMessageComponentCollector({ filter, time: 15_000 }); - * collector.on('collect', i => console.log(`Collected ${i.customId}`)); + * collector.on('collect', interaction => console.log(`Collected ${interaction.customId}`)); * collector.on('end', collected => console.log(`Collected ${collected.size} items`)); */ createMessageComponentCollector(options = {}) { @@ -272,7 +272,8 @@ class TextBasedChannel { */ async bulkDelete(messages, filterOld = false) { if (Array.isArray(messages) || messages instanceof Collection) { - let messageIds = messages instanceof Collection ? [...messages.keys()] : messages.map(m => m.id ?? m); + let messageIds = + messages instanceof Collection ? [...messages.keys()] : messages.map(message => message.id ?? message); if (filterOld) { messageIds = messageIds.filter( id => Date.now() - DiscordSnowflake.timestampFrom(id) < MaxBulkDeletableMessageAge, diff --git a/packages/discord.js/src/util/BitField.js b/packages/discord.js/src/util/BitField.js index f0778f68807a..917d69132d16 100644 --- a/packages/discord.js/src/util/BitField.js +++ b/packages/discord.js/src/util/BitField.js @@ -164,7 +164,9 @@ class BitField { const { DefaultBit } = this; if (typeof DefaultBit === typeof bit && bit >= DefaultBit) return bit; if (bit instanceof BitField) return bit.bitfield; - if (Array.isArray(bit)) return bit.map(p => this.resolve(p)).reduce((prev, p) => prev | p, DefaultBit); + if (Array.isArray(bit)) { + return bit.map(bit_ => this.resolve(bit_)).reduce((prev, bit_) => prev | bit_, DefaultBit); + } if (typeof bit === 'string') { if (!isNaN(bit)) return typeof DefaultBit === 'bigint' ? BigInt(bit) : Number(bit); if (this.Flags[bit] !== undefined) return this.Flags[bit]; diff --git a/packages/discord.js/src/util/Util.js b/packages/discord.js/src/util/Util.js index 5814af103002..e49c43b4a6f4 100644 --- a/packages/discord.js/src/util/Util.js +++ b/packages/discord.js/src/util/Util.js @@ -18,8 +18,8 @@ function flatten(obj, ...props) { if (!isObject(obj)) return obj; const objProps = Object.keys(obj) - .filter(k => !k.startsWith('_')) - .map(k => ({ [k]: true })); + .filter(key => !key.startsWith('_')) + .map(key => ({ [key]: true })); props = objProps.length ? Object.assign(...objProps, ...props) : Object.assign({}, ...props); @@ -39,7 +39,7 @@ function flatten(obj, ...props) { // If the valueOf is a Collection, use its array of keys else if (valueOf instanceof Collection) out[newProp] = Array.from(valueOf.keys()); // If it's an array, call toJSON function on each element if present, otherwise flatten each element - else if (Array.isArray(element)) out[newProp] = element.map(e => e.toJSON?.() ?? flatten(e)); + else if (Array.isArray(element)) out[newProp] = element.map(elm => elm.toJSON?.() ?? flatten(elm)); // If it's an object with a primitive `valueOf`, use that value else if (typeof valueOf !== 'object') out[newProp] = valueOf; // If it's an object with a toJSON function, use the return value of it diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index 6b5f4f16f6b8..3f77396d598c 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -364,8 +364,8 @@ client.on('messageCreate', async message => { // https://github.com/discordjs/discord.js/issues/8545 { // These should not throw any errors when comparing messages from any source. - channel.messages.cache.filter(m => m); - (await channel.messages.fetch()).filter(m => m.author.id === message.author.id); + channel.messages.cache.filter(message => message); + (await channel.messages.fetch()).filter(({ author }) => author.id === message.author.id); if (channel.isDMBased()) { expectType(channel.messages.channel.messages); @@ -2047,7 +2047,7 @@ collector.on('end', (collection, reason) => { } })(); -expectType>(shard.eval(c => c.readyTimestamp)); +expectType>(shard.eval(client => client.readyTimestamp)); // Test audit logs expectType>>(guild.fetchAuditLogs({ type: AuditLogEvent.MemberKick }));