diff --git a/packages/discord.js/src/managers/CategoryChannelChildManager.js b/packages/discord.js/src/managers/CategoryChannelChildManager.js index e84c0ec47..bd594fd40 100644 --- a/packages/discord.js/src/managers/CategoryChannelChildManager.js +++ b/packages/discord.js/src/managers/CategoryChannelChildManager.js @@ -38,6 +38,7 @@ class CategoryChannelChildManager extends DataManager { /** * Options for creating a channel using {@link CategoryChannel#createChannel}. * @typedef {Object} CategoryCreateChannelOptions + * @property {string} name The name for the new channel * @property {ChannelType} [type=ChannelType.GuildText] The type of the new channel. * @property {string} [topic] The topic for the new channel * @property {boolean} [nsfw] Whether the new channel is NSFW @@ -55,12 +56,11 @@ class CategoryChannelChildManager extends DataManager { /** * Creates a new channel within this category. * You cannot create a channel of type {@link ChannelType.GuildCategory} inside a CategoryChannel. - * @param {string} name The name of the new channel * @param {CategoryCreateChannelOptions} options Options for creating the new channel * @returns {Promise} */ - create(name, options) { - return this.guild.channels.create(name, { + create(options) { + return this.guild.channels.create({ ...options, parent: this.channel.id, }); diff --git a/packages/discord.js/src/managers/GuildChannelManager.js b/packages/discord.js/src/managers/GuildChannelManager.js index 22a7eaca8..37919189a 100644 --- a/packages/discord.js/src/managers/GuildChannelManager.js +++ b/packages/discord.js/src/managers/GuildChannelManager.js @@ -104,17 +104,17 @@ class GuildChannelManager extends CachedManager { /** * Creates a new channel in the guild. - * @param {string} name The name of the new channel - * @param {GuildChannelCreateOptions} [options={}] Options for creating the new channel + * @param {GuildChannelCreateOptions} options Options for creating the new channel * @returns {Promise} * @example * // Create a new text channel - * guild.channels.create('new-general', { reason: 'Needed a cool new channel' }) + * guild.channels.create({ name: 'new-general', reason: 'Needed a cool new channel' }) * .then(console.log) * .catch(console.error); * @example * // Create a new channel with permission overwrites - * guild.channels.create('new-voice', { + * guild.channels.create({ + * name: 'new-general', * type: ChannelType.GuildVoice, * permissionOverwrites: [ * { @@ -124,23 +124,21 @@ class GuildChannelManager extends CachedManager { * ], * }) */ - async create( + async create({ name, - { - type, - topic, - nsfw, - bitrate, - userLimit, - parent, - permissionOverwrites, - position, - rateLimitPerUser, - rtcRegion, - videoQualityMode, - reason, - } = {}, - ) { + type, + topic, + nsfw, + bitrate, + userLimit, + parent, + permissionOverwrites, + position, + rateLimitPerUser, + rtcRegion, + videoQualityMode, + reason, + }) { parent &&= this.client.channels.resolveId(parent); permissionOverwrites &&= permissionOverwrites.map(o => PermissionOverwrites.resolve(o, this.guild)); @@ -164,22 +162,27 @@ class GuildChannelManager extends CachedManager { return this.client.actions.ChannelCreate.handle(data).channel; } + /** + * @typedef {ChannelWebhookCreateOptions} WebhookCreateOptions + * @property {GuildChannelResolvable} channel The channel to create the webhook for + */ + /** * Creates a webhook for the channel. - * @param {GuildChannelResolvable} channel The channel to create the webhook for - * @param {string} name The name of the webhook - * @param {ChannelWebhookCreateOptions} [options] Options for creating the webhook + * @param {WebhookCreateOptions} options Options for creating the webhook * @returns {Promise} Returns the created Webhook * @example * // Create a webhook for the current channel - * guild.channels.createWebhook('222197033908436994', 'Snek', { + * guild.channels.createWebhook({ + * channel: '222197033908436994', + * name: 'Snek', * avatar: 'https://i.imgur.com/mI8XcpG.jpg', * reason: 'Needed a cool new Webhook' * }) * .then(console.log) * .catch(console.error) */ - async createWebhook(channel, name, { avatar, reason } = {}) { + async createWebhook({ channel, name, avatar, reason }) { const id = this.resolveId(channel); if (!id) throw new TypeError('INVALID_TYPE', 'channel', 'GuildChannelResolvable'); if (typeof avatar === 'string' && !avatar.startsWith('data:')) { @@ -215,13 +218,13 @@ class GuildChannelManager extends CachedManager { * The default auto archive duration for all new threads in this channel * @property {?string} [rtcRegion] The RTC region of the channel * @property {?VideoQualityMode} [videoQualityMode] The camera video quality mode of the channel + * @property {string} [reason] Reason for editing this channel */ /** * Edits the channel. * @param {GuildChannelResolvable} channel The channel to edit * @param {ChannelData} data The new data for the channel - * @param {string} [reason] Reason for editing this channel * @returns {Promise} * @example * // Edit a channel @@ -229,13 +232,15 @@ class GuildChannelManager extends CachedManager { * .then(console.log) * .catch(console.error); */ - async edit(channel, data, reason) { + async edit(channel, data) { channel = this.resolve(channel); if (!channel) throw new TypeError('INVALID_TYPE', 'channel', 'GuildChannelResolvable'); const parent = data.parent && this.client.channels.resolveId(data.parent); - if (typeof data.position !== 'undefined') await this.setPosition(channel, data.position, { reason }); + if (typeof data.position !== 'undefined') { + await this.setPosition(channel, data.position, { position: data.position, reason: data.reason }); + } let permission_overwrites = data.permissionOverwrites?.map(o => PermissionOverwrites.resolve(o, this.guild)); @@ -270,7 +275,7 @@ class GuildChannelManager extends CachedManager { default_auto_archive_duration: data.defaultAutoArchiveDuration, permission_overwrites, }, - reason, + reason: data.reason, }); return this.client.actions.ChannelUpdate.handle(newData).updated; @@ -280,7 +285,7 @@ class GuildChannelManager extends CachedManager { * Sets a new position for the guild channel. * @param {GuildChannelResolvable} channel The channel to set the position for * @param {number} position The new position for the guild channel - * @param {SetChannelPositionOptions} [options] Options for setting position + * @param {SetChannelPositionOptions} options Options for setting position * @returns {Promise} * @example * // Set a new channel position diff --git a/packages/discord.js/src/managers/GuildEmojiManager.js b/packages/discord.js/src/managers/GuildEmojiManager.js index 8668064af..a376fd979 100644 --- a/packages/discord.js/src/managers/GuildEmojiManager.js +++ b/packages/discord.js/src/managers/GuildEmojiManager.js @@ -27,29 +27,29 @@ class GuildEmojiManager extends BaseGuildEmojiManager { /** * Options used for creating an emoji in a guild. - * @typedef {Object} GuildEmojiCreateOptions + * @typedef {Object} + * @property {BufferResolvable|Base64Resolvable} attachment The image for the emoji + * @property {string} name The name for the emoji * @property {Collection|RoleResolvable[]} [roles] The roles to limit the emoji to * @property {string} [reason] The reason for creating the emoji */ /** * Creates a new custom emoji in the guild. - * @param {BufferResolvable|Base64Resolvable} attachment The image for the emoji - * @param {string} name The name for the emoji - * @param {GuildEmojiCreateOptions} [options] Options for creating the emoji + * @param {GuildEmojiCreateOptions} options Options for creating the emoji * @returns {Promise} The created emoji * @example * // Create a new emoji from a URL - * guild.emojis.create('https://i.imgur.com/w3duR07.png', 'rip') + * guild.emojis.create({ attachment: 'https://i.imgur.com/w3duR07.png', name: 'rip' }) * .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`)) * .catch(console.error); * @example * // Create a new emoji from a file on your computer - * guild.emojis.create('./memes/banana.png', 'banana') + * guild.emojis.create({ attachment: './memes/banana.png', name: 'banana' }) * .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`)) * .catch(console.error); */ - async create(attachment, name, { roles, reason } = {}) { + async create({ attachment, name, roles, reason }) { attachment = await DataResolver.resolveImage(attachment); if (!attachment) throw new TypeError('REQ_RESOURCE_TYPE'); @@ -118,10 +118,9 @@ class GuildEmojiManager extends BaseGuildEmojiManager { * Edits an emoji. * @param {EmojiResolvable} emoji The Emoji resolvable to edit * @param {GuildEmojiEditData} data The new data for the emoji - * @param {string} [reason] Reason for editing this emoji * @returns {Promise} */ - async edit(emoji, data, reason) { + async edit(emoji, data) { const id = this.resolveId(emoji); if (!id) throw new TypeError('INVALID_TYPE', 'emoji', 'EmojiResolvable', true); const roles = data.roles?.map(r => this.guild.roles.resolveId(r)); @@ -130,7 +129,7 @@ class GuildEmojiManager extends BaseGuildEmojiManager { name: data.name, roles, }, - reason, + reason: data.reason, }); const existing = this.cache.get(id); if (existing) { diff --git a/packages/discord.js/src/managers/GuildManager.js b/packages/discord.js/src/managers/GuildManager.js index 4450dfe0b..ea4545739 100644 --- a/packages/discord.js/src/managers/GuildManager.js +++ b/packages/discord.js/src/managers/GuildManager.js @@ -141,6 +141,7 @@ class GuildManager extends CachedManager { /** * Options used to create a guild. * @typedef {Object} GuildCreateOptions + * @property {string} name The name of the guild * @property {Snowflake|number} [afkChannelId] The AFK channel's id * @property {number} [afkTimeout] The AFK timeout in seconds * @property {PartialChannelData[]} [channels=[]] The channels for this guild @@ -159,25 +160,22 @@ class GuildManager extends CachedManager { /** * Creates a guild. * This is only available to bots in fewer than 10 guilds. - * @param {string} name The name of the guild - * @param {GuildCreateOptions} [options] Options for creating the guild + * @param {GuildCreateOptions} options Options for creating the guild * @returns {Promise} The guild that was created */ - async create( + async create({ name, - { - afkChannelId, - afkTimeout, - channels = [], - defaultMessageNotifications, - explicitContentFilter, - icon = null, - roles = [], - systemChannelId, - systemChannelFlags, - verificationLevel, - } = {}, - ) { + afkChannelId, + afkTimeout, + channels = [], + defaultMessageNotifications, + explicitContentFilter, + icon = null, + roles = [], + systemChannelId, + systemChannelFlags, + verificationLevel, + }) { icon = await DataResolver.resolveImage(icon); for (const channel of channels) { diff --git a/packages/discord.js/src/managers/GuildMemberManager.js b/packages/discord.js/src/managers/GuildMemberManager.js index d738d19c5..adabe3c93 100644 --- a/packages/discord.js/src/managers/GuildMemberManager.js +++ b/packages/discord.js/src/managers/GuildMemberManager.js @@ -265,6 +265,7 @@ class GuildMemberManager extends CachedManager { * (if they are connected to voice), or `null` if you want to disconnect them from voice * @property {DateResolvable|null} [communicationDisabledUntil] The date or timestamp * for the member's communication to be disabled until. Provide `null` to enable communication again. + * @property {string} [reason] Reason for editing this user */ /** @@ -272,33 +273,30 @@ class GuildMemberManager extends CachedManager { * The user must be a member of the guild * @param {UserResolvable} user The member to edit * @param {GuildMemberEditData} data The data to edit the member with - * @param {string} [reason] Reason for editing this user * @returns {Promise} */ - async edit(user, data, reason) { + async edit(user, { reason, ...data }) { const id = this.client.users.resolveId(user); if (!id) throw new TypeError('INVALID_TYPE', 'user', 'UserResolvable'); - // Clone the data object for immutability - const _data = { ...data }; - if (_data.channel) { - _data.channel = this.guild.channels.resolve(_data.channel); - if (!(_data.channel instanceof BaseGuildVoiceChannel)) { + if (data.channel) { + data.channel = this.guild.channels.resolve(data.channel); + if (!(data.channel instanceof BaseGuildVoiceChannel)) { throw new Error('GUILD_VOICE_CHANNEL_RESOLVE'); } - _data.channel_id = _data.channel.id; - _data.channel = undefined; - } else if (_data.channel === null) { - _data.channel_id = null; - _data.channel = undefined; + data.channel_id = data.channel.id; + data.channel = undefined; + } else if (data.channel === null) { + data.channel_id = null; + data.channel = undefined; } - _data.roles &&= _data.roles.map(role => (role instanceof Role ? role.id : role)); + data.roles &&= data.roles.map(role => (role instanceof Role ? role.id : role)); - _data.communication_disabled_until = + data.communication_disabled_until = // eslint-disable-next-line eqeqeq - _data.communicationDisabledUntil != null - ? new Date(_data.communicationDisabledUntil).toISOString() - : _data.communicationDisabledUntil; + data.communicationDisabledUntil != null + ? new Date(data.communicationDisabledUntil).toISOString() + : data.communicationDisabledUntil; let endpoint; if (id === this.client.user.id) { @@ -308,7 +306,7 @@ class GuildMemberManager extends CachedManager { } else { endpoint = Routes.guildMember(this.guild.id, id); } - const d = await this.client.rest.patch(endpoint, { body: _data, reason }); + const d = await this.client.rest.patch(endpoint, { body: data, reason }); const clone = this.cache.get(id)?._clone(); clone?._patch(d); diff --git a/packages/discord.js/src/managers/GuildMemberRoleManager.js b/packages/discord.js/src/managers/GuildMemberRoleManager.js index 20ffe8644..e6712ded0 100644 --- a/packages/discord.js/src/managers/GuildMemberRoleManager.js +++ b/packages/discord.js/src/managers/GuildMemberRoleManager.js @@ -179,7 +179,7 @@ class GuildMemberRoleManager extends DataManager { * .catch(console.error); */ set(roles, reason) { - return this.member.edit({ roles }, reason); + return this.member.edit({ roles, reason }); } clone() { diff --git a/packages/discord.js/src/managers/GuildStickerManager.js b/packages/discord.js/src/managers/GuildStickerManager.js index 4e1864451..594eb3eb7 100644 --- a/packages/discord.js/src/managers/GuildStickerManager.js +++ b/packages/discord.js/src/managers/GuildStickerManager.js @@ -35,16 +35,16 @@ class GuildStickerManager extends CachedManager { /** * Options for creating a guild sticker. * @typedef {Object} GuildStickerCreateOptions + * @property {BufferResolvable|Stream|JSONEncodable} file The file for the sticker + * @property {string} name The name for the sticker + * @property {string} tags The Discord name of a unicode emoji representing the sticker's expression * @property {?string} [description] The description for the sticker * @property {string} [reason] Reason for creating the sticker */ /** * Creates a new custom sticker in the guild. - * @param {BufferResolvable|Stream|JSONEncodable} file The file for the sticker - * @param {string} name The name for the sticker - * @param {string} tags The Discord name of a unicode emoji representing the sticker's expression - * @param {GuildStickerCreateOptions} [options] Options + * @param {GuildStickerCreateOptions} options Options * @returns {Promise} The created sticker * @example * // Create a new sticker from a URL @@ -57,7 +57,7 @@ class GuildStickerManager extends CachedManager { * .then(sticker => console.log(`Created new sticker with name ${sticker.name}!`)) * .catch(console.error); */ - async create(file, name, tags, { description, reason } = {}) { + async create({ file, name, tags, description, reason } = {}) { const resolvedFile = await MessagePayload.resolveFile(file); if (!resolvedFile) throw new TypeError('REQ_RESOURCE_TYPE'); file = { ...resolvedFile, key: 'file' }; @@ -101,17 +101,16 @@ class GuildStickerManager extends CachedManager { /** * Edits a sticker. * @param {StickerResolvable} sticker The sticker to edit - * @param {GuildStickerEditData} [data] The new data for the sticker - * @param {string} [reason] Reason for editing this sticker + * @param {GuildStickerEditData} [data={}] The new data for the sticker * @returns {Promise} */ - async edit(sticker, data, reason) { + async edit(sticker, data = {}) { const stickerId = this.resolveId(sticker); if (!stickerId) throw new TypeError('INVALID_TYPE', 'sticker', 'StickerResolvable'); const d = await this.client.rest.patch(Routes.guildSticker(this.guild.id, stickerId), { body: data, - reason, + reason: data.reason, }); const existing = this.cache.get(stickerId); diff --git a/packages/discord.js/src/managers/RoleManager.js b/packages/discord.js/src/managers/RoleManager.js index 8f9eb2fc5..0bfc7465b 100644 --- a/packages/discord.js/src/managers/RoleManager.js +++ b/packages/discord.js/src/managers/RoleManager.js @@ -165,11 +165,16 @@ class RoleManager extends CachedManager { return role; } + /** + * Options for editing a role + * @typedef {RoleData} EditRoleOptions + * @property {string} [reason] The reason for editing this role + */ + /** * Edits a role of the guild. * @param {RoleResolvable} role The role to edit - * @param {RoleData} data The new data for the role - * @param {string} [reason] Reason for editing this role + * @param {EditRoleOptions} data The new data for the role * @returns {Promise} * @example * // Edit a role @@ -177,12 +182,12 @@ class RoleManager extends CachedManager { * .then(updated => console.log(`Edited role name to ${updated.name}`)) * .catch(console.error); */ - async edit(role, data, reason) { + async edit(role, data) { role = this.resolve(role); if (!role) throw new TypeError('INVALID_TYPE', 'role', 'RoleResolvable'); if (typeof data.position === 'number') { - await this.setPosition(role, data.position, { reason }); + await this.setPosition(role, data.position, { reason: data.reason }); } let icon = data.icon; @@ -202,7 +207,7 @@ class RoleManager extends CachedManager { unicode_emoji: data.unicodeEmoji, }; - const d = await this.client.rest.patch(Routes.guildRole(this.guild.id, role.id), { body, reason }); + const d = await this.client.rest.patch(Routes.guildRole(this.guild.id, role.id), { body, reason: data.reason }); const clone = role._clone(); clone._patch(d); diff --git a/packages/discord.js/src/structures/BaseGuildTextChannel.js b/packages/discord.js/src/structures/BaseGuildTextChannel.js index 06e5473bc..e0dfd58ff 100644 --- a/packages/discord.js/src/structures/BaseGuildTextChannel.js +++ b/packages/discord.js/src/structures/BaseGuildTextChannel.js @@ -86,7 +86,7 @@ class BaseGuildTextChannel extends GuildChannel { * @returns {Promise} */ setDefaultAutoArchiveDuration(defaultAutoArchiveDuration, reason) { - return this.edit({ defaultAutoArchiveDuration }, reason); + return this.edit({ defaultAutoArchiveDuration, reason }); } /** @@ -96,7 +96,7 @@ class BaseGuildTextChannel extends GuildChannel { * @returns {Promise} */ setType(type, reason) { - return this.edit({ type }, reason); + return this.edit({ type, reason }); } /** @@ -111,7 +111,7 @@ class BaseGuildTextChannel extends GuildChannel { * .catch(console.error); */ setTopic(topic, reason) { - return this.edit({ topic }, reason); + return this.edit({ topic, reason }); } /** diff --git a/packages/discord.js/src/structures/BaseGuildVoiceChannel.js b/packages/discord.js/src/structures/BaseGuildVoiceChannel.js index b40adaf24..57d6bf26f 100644 --- a/packages/discord.js/src/structures/BaseGuildVoiceChannel.js +++ b/packages/discord.js/src/structures/BaseGuildVoiceChannel.js @@ -93,7 +93,7 @@ class BaseGuildVoiceChannel extends GuildChannel { * channel.setRTCRegion(null, 'We want to let Discord decide.'); */ setRTCRegion(rtcRegion, reason) { - return this.edit({ rtcRegion }, reason); + return this.edit({ rtcRegion, reason }); } /** diff --git a/packages/discord.js/src/structures/Guild.js b/packages/discord.js/src/structures/Guild.js index 244e13df0..cc2f98730 100644 --- a/packages/discord.js/src/structures/Guild.js +++ b/packages/discord.js/src/structures/Guild.js @@ -737,6 +737,7 @@ class Guild extends AnonymousGuild { * @property {boolean} [premiumProgressBarEnabled] Whether the guild's premium progress bar is enabled * @property {?string} [description] The discovery description of the guild * @property {GuildFeature[]} [features] The features of the guild + * @property {string} [reason] Reason for editing this guild */ /* eslint-enable max-len */ @@ -757,7 +758,6 @@ class Guild extends AnonymousGuild { /** * Updates the guild with new information - e.g. a new name. * @param {GuildEditData} data The data to update the guild with - * @param {string} [reason] Reason for editing this guild * @returns {Promise} * @example * // Set the guild name @@ -767,7 +767,7 @@ class Guild extends AnonymousGuild { * .then(updated => console.log(`New guild name ${updated}`)) * .catch(console.error); */ - async edit(data, reason) { + async edit(data) { const _data = {}; if (data.name) _data.name = data.name; if (typeof data.verificationLevel !== 'undefined') { @@ -810,7 +810,7 @@ class Guild extends AnonymousGuild { } if (typeof data.preferredLocale !== 'undefined') _data.preferred_locale = data.preferredLocale; if ('premiumProgressBarEnabled' in data) _data.premium_progress_bar_enabled = data.premiumProgressBarEnabled; - const newData = await this.client.rest.patch(Routes.guild(this.id), { body: _data, reason }); + const newData = await this.client.rest.patch(Routes.guild(this.id), { body: _data, reason: data.reason }); return this.client.actions.GuildUpdate.handle(newData).updated; } @@ -892,7 +892,7 @@ class Guild extends AnonymousGuild { * @returns {Promise} */ setExplicitContentFilter(explicitContentFilter, reason) { - return this.edit({ explicitContentFilter }, reason); + return this.edit({ explicitContentFilter, reason }); } /** @@ -902,7 +902,7 @@ class Guild extends AnonymousGuild { * @returns {Promise} */ setDefaultMessageNotifications(defaultMessageNotifications, reason) { - return this.edit({ defaultMessageNotifications }, reason); + return this.edit({ defaultMessageNotifications, reason }); } /* eslint-enable max-len */ @@ -913,7 +913,7 @@ class Guild extends AnonymousGuild { * @returns {Promise} */ setSystemChannelFlags(systemChannelFlags, reason) { - return this.edit({ systemChannelFlags }, reason); + return this.edit({ systemChannelFlags, reason }); } /** @@ -928,7 +928,7 @@ class Guild extends AnonymousGuild { * .catch(console.error); */ setName(name, reason) { - return this.edit({ name }, reason); + return this.edit({ name, reason }); } /** @@ -943,7 +943,7 @@ class Guild extends AnonymousGuild { * .catch(console.error); */ setVerificationLevel(verificationLevel, reason) { - return this.edit({ verificationLevel }, reason); + return this.edit({ verificationLevel, reason }); } /** @@ -958,7 +958,7 @@ class Guild extends AnonymousGuild { * .catch(console.error); */ setAFKChannel(afkChannel, reason) { - return this.edit({ afkChannel }, reason); + return this.edit({ afkChannel, reason }); } /** @@ -973,7 +973,7 @@ class Guild extends AnonymousGuild { * .catch(console.error); */ setSystemChannel(systemChannel, reason) { - return this.edit({ systemChannel }, reason); + return this.edit({ systemChannel, reason }); } /** @@ -988,7 +988,7 @@ class Guild extends AnonymousGuild { * .catch(console.error); */ setAFKTimeout(afkTimeout, reason) { - return this.edit({ afkTimeout }, reason); + return this.edit({ afkTimeout, reason }); } /** @@ -1003,7 +1003,7 @@ class Guild extends AnonymousGuild { * .catch(console.error); */ setIcon(icon, reason) { - return this.edit({ icon }, reason); + return this.edit({ icon, reason }); } /** @@ -1019,7 +1019,7 @@ class Guild extends AnonymousGuild { * .catch(console.error); */ setOwner(owner, reason) { - return this.edit({ owner }, reason); + return this.edit({ owner, reason }); } /** @@ -1034,7 +1034,7 @@ class Guild extends AnonymousGuild { * .catch(console.error); */ setSplash(splash, reason) { - return this.edit({ splash }, reason); + return this.edit({ splash, reason }); } /** @@ -1049,7 +1049,7 @@ class Guild extends AnonymousGuild { * .catch(console.error); */ setDiscoverySplash(discoverySplash, reason) { - return this.edit({ discoverySplash }, reason); + return this.edit({ discoverySplash, reason }); } /** @@ -1063,7 +1063,7 @@ class Guild extends AnonymousGuild { * .catch(console.error); */ setBanner(banner, reason) { - return this.edit({ banner }, reason); + return this.edit({ banner, reason }); } /** @@ -1078,7 +1078,7 @@ class Guild extends AnonymousGuild { * .catch(console.error); */ setRulesChannel(rulesChannel, reason) { - return this.edit({ rulesChannel }, reason); + return this.edit({ rulesChannel, reason }); } /** @@ -1093,7 +1093,7 @@ class Guild extends AnonymousGuild { * .catch(console.error); */ setPublicUpdatesChannel(publicUpdatesChannel, reason) { - return this.edit({ publicUpdatesChannel }, reason); + return this.edit({ publicUpdatesChannel, reason }); } /** @@ -1108,7 +1108,7 @@ class Guild extends AnonymousGuild { * .catch(console.error); */ setPreferredLocale(preferredLocale, reason) { - return this.edit({ preferredLocale }, reason); + return this.edit({ preferredLocale, reason }); } /** @@ -1118,7 +1118,7 @@ class Guild extends AnonymousGuild { * @returns {Promise} */ setPremiumProgressBarEnabled(enabled = true, reason) { - return this.edit({ premiumProgressBarEnabled: enabled }, reason); + return this.edit({ premiumProgressBarEnabled: enabled, reason }); } /** diff --git a/packages/discord.js/src/structures/GuildChannel.js b/packages/discord.js/src/structures/GuildChannel.js index 3a7ce5b9f..a877e435a 100644 --- a/packages/discord.js/src/structures/GuildChannel.js +++ b/packages/discord.js/src/structures/GuildChannel.js @@ -264,8 +264,7 @@ class GuildChannel extends Channel { /** * Edits the channel. - * @param {ChannelData} data The new data for the channel - * @param {string} [reason] Reason for editing this channel + * @param {ChannelEditData} data The new data for the channel * @returns {Promise} * @example * // Edit a channel @@ -273,8 +272,8 @@ class GuildChannel extends Channel { * .then(console.log) * .catch(console.error); */ - edit(data, reason) { - return this.guild.channels.edit(this, data, reason); + edit(data) { + return this.guild.channels.edit(this, data); } /** @@ -289,7 +288,7 @@ class GuildChannel extends Channel { * .catch(console.error); */ setName(name, reason) { - return this.edit({ name }, reason); + return this.edit({ name, reason }); } /** @@ -311,13 +310,11 @@ class GuildChannel extends Channel { * .catch(console.error); */ setParent(channel, { lockPermissions = true, reason } = {}) { - return this.edit( - { - parent: channel ?? null, - lockPermissions, - }, + return this.edit({ + parent: channel ?? null, + lockPermissions, reason, - ); + }); } /** @@ -354,7 +351,8 @@ class GuildChannel extends Channel { * @returns {Promise} */ clone(options = {}) { - return this.guild.channels.create(options.name ?? this.name, { + return this.guild.channels.create({ + name: options.name ?? this.name, permissionOverwrites: this.permissionOverwrites.cache, topic: this.topic, type: this.type, diff --git a/packages/discord.js/src/structures/GuildEmoji.js b/packages/discord.js/src/structures/GuildEmoji.js index b0a8ff2fd..d3c586a3b 100644 --- a/packages/discord.js/src/structures/GuildEmoji.js +++ b/packages/discord.js/src/structures/GuildEmoji.js @@ -81,12 +81,12 @@ class GuildEmoji extends BaseGuildEmoji { * @typedef {Object} GuildEmojiEditData * @property {string} [name] The name of the emoji * @property {Collection|RoleResolvable[]} [roles] Roles to restrict emoji to + * @property {string} [reason] Reason for editing this emoji */ /** * Edits the emoji. * @param {GuildEmojiEditData} data The new data for the emoji - * @param {string} [reason] Reason for editing this emoji * @returns {Promise} * @example * // Edit an emoji @@ -94,8 +94,8 @@ class GuildEmoji extends BaseGuildEmoji { * .then(e => console.log(`Edited emoji ${e}`)) * .catch(console.error); */ - edit(data, reason) { - return this.guild.emojis.edit(this.id, data, reason); + edit(data) { + return this.guild.emojis.edit(this.id, data); } /** @@ -105,7 +105,7 @@ class GuildEmoji extends BaseGuildEmoji { * @returns {Promise} */ setName(name, reason) { - return this.edit({ name }, reason); + return this.edit({ name, reason }); } /** diff --git a/packages/discord.js/src/structures/GuildMember.js b/packages/discord.js/src/structures/GuildMember.js index f732ca754..2da967d34 100644 --- a/packages/discord.js/src/structures/GuildMember.js +++ b/packages/discord.js/src/structures/GuildMember.js @@ -299,11 +299,10 @@ class GuildMember extends Base { /** * Edits this member. * @param {GuildMemberEditData} data The data to edit the member with - * @param {string} [reason] Reason for editing this user * @returns {Promise} */ - edit(data, reason) { - return this.guild.members.edit(this, data, reason); + edit(data) { + return this.guild.members.edit(this, data); } /** @@ -313,7 +312,7 @@ class GuildMember extends Base { * @returns {Promise} */ setNickname(nick, reason) { - return this.edit({ nick }, reason); + return this.edit({ nick, reason }); } /** @@ -369,7 +368,7 @@ class GuildMember extends Base { * .catch(console.error); */ disableCommunicationUntil(communicationDisabledUntil, reason) { - return this.edit({ communicationDisabledUntil }, reason); + return this.edit({ communicationDisabledUntil, reason }); } /** diff --git a/packages/discord.js/src/structures/Role.js b/packages/discord.js/src/structures/Role.js index a6260c7cd..abba946de 100644 --- a/packages/discord.js/src/structures/Role.js +++ b/packages/discord.js/src/structures/Role.js @@ -207,8 +207,7 @@ class Role extends Base { /** * Edits the role. - * @param {RoleData} data The new data for the role - * @param {string} [reason] Reason for editing this role + * @param {EditRoleOptions} data The new data for the role * @returns {Promise} * @example * // Edit a role @@ -216,8 +215,8 @@ class Role extends Base { * .then(updated => console.log(`Edited role name to ${updated.name}`)) * .catch(console.error); */ - edit(data, reason) { - return this.guild.roles.edit(this, data, reason); + edit(data) { + return this.guild.roles.edit(this, data); } /** @@ -245,7 +244,7 @@ class Role extends Base { * .catch(console.error); */ setName(name, reason) { - return this.edit({ name }, reason); + return this.edit({ name, reason }); } /** @@ -260,7 +259,7 @@ class Role extends Base { * .catch(console.error); */ setColor(color, reason) { - return this.edit({ color }, reason); + return this.edit({ color, reason }); } /** @@ -275,7 +274,7 @@ class Role extends Base { * .catch(console.error); */ setHoist(hoist = true, reason) { - return this.edit({ hoist }, reason); + return this.edit({ hoist, reason }); } /** @@ -295,7 +294,7 @@ class Role extends Base { * .catch(console.error); */ setPermissions(permissions, reason) { - return this.edit({ permissions }, reason); + return this.edit({ permissions, reason }); } /** @@ -310,7 +309,7 @@ class Role extends Base { * .catch(console.error); */ setMentionable(mentionable = true, reason) { - return this.edit({ mentionable }, reason); + return this.edit({ mentionable, reason }); } /** @@ -322,7 +321,7 @@ class Role extends Base { * @returns {Promise} */ setIcon(icon, reason) { - return this.edit({ icon }, reason); + return this.edit({ icon, reason }); } /** @@ -337,7 +336,7 @@ class Role extends Base { * .catch(console.error); */ setUnicodeEmoji(unicodeEmoji, reason) { - return this.edit({ unicodeEmoji }, reason); + return this.edit({ unicodeEmoji, reason }); } /** diff --git a/packages/discord.js/src/structures/StageChannel.js b/packages/discord.js/src/structures/StageChannel.js index b57beb5cb..14070c475 100644 --- a/packages/discord.js/src/structures/StageChannel.js +++ b/packages/discord.js/src/structures/StageChannel.js @@ -49,7 +49,7 @@ class StageChannel extends BaseGuildVoiceChannel { * .catch(console.error); */ setTopic(topic, reason) { - return this.edit({ topic }, reason); + return this.edit({ topic, reason }); } /** diff --git a/packages/discord.js/src/structures/Sticker.js b/packages/discord.js/src/structures/Sticker.js index 9c5cdfe8a..ffb36c975 100644 --- a/packages/discord.js/src/structures/Sticker.js +++ b/packages/discord.js/src/structures/Sticker.js @@ -200,12 +200,12 @@ class Sticker extends Base { * @property {string} [name] The name of the sticker * @property {?string} [description] The description of the sticker * @property {string} [tags] The Discord name of a unicode emoji representing the sticker's expression + * @property {string} [reason] Reason for editing this sticker */ /** * Edits the sticker. - * @param {GuildStickerEditData} [data] The new data for the sticker - * @param {string} [reason] Reason for editing this sticker + * @param {GuildStickerEditData} data The new data for the sticker * @returns {Promise} * @example * // Update the name of a sticker @@ -213,8 +213,8 @@ class Sticker extends Base { * .then(s => console.log(`Updated the name of the sticker to ${s.name}`)) * .catch(console.error); */ - edit(data, reason) { - return this.guild.stickers.edit(this, data, reason); + edit(data) { + return this.guild.stickers.edit(this, data); } /** diff --git a/packages/discord.js/src/structures/TextChannel.js b/packages/discord.js/src/structures/TextChannel.js index 97040a2ab..66cc8c450 100644 --- a/packages/discord.js/src/structures/TextChannel.js +++ b/packages/discord.js/src/structures/TextChannel.js @@ -26,7 +26,7 @@ class TextChannel extends BaseGuildTextChannel { * @returns {Promise} */ setRateLimitPerUser(rateLimitPerUser, reason) { - return this.edit({ rateLimitPerUser }, reason); + return this.edit({ rateLimitPerUser, reason }); } } diff --git a/packages/discord.js/src/structures/ThreadChannel.js b/packages/discord.js/src/structures/ThreadChannel.js index 717af2c31..35895f2cc 100644 --- a/packages/discord.js/src/structures/ThreadChannel.js +++ b/packages/discord.js/src/structures/ThreadChannel.js @@ -297,13 +297,13 @@ class ThreadChannel extends Channel { * @property {number} [rateLimitPerUser] The rate limit per user (slowmode) for the thread in seconds * @property {boolean} [locked] Whether the thread is locked * @property {boolean} [invitable] Whether non-moderators can add other non-moderators to a thread + * @property {string} [reason] Reason for editing the thread * Can only be edited on {@link ChannelType.GuildPrivateThread} */ /** * Edits this thread. * @param {ThreadEditData} data The new data for this thread - * @param {string} [reason] Reason for editing this thread * @returns {Promise} * @example * // Edit a thread @@ -311,7 +311,7 @@ class ThreadChannel extends Channel { * .then(editedThread => console.log(editedThread)) * .catch(console.error); */ - async edit(data, reason) { + async edit(data) { const newData = await this.client.rest.patch(Routes.channel(this.id), { body: { name: (data.name ?? this.name).trim(), @@ -321,7 +321,7 @@ class ThreadChannel extends Channel { locked: data.locked, invitable: this.type === ChannelType.GuildPrivateThread ? data.invitable : undefined, }, - reason, + reason: data.reason, }); return this.client.actions.ChannelUpdate.handle(newData).updated; @@ -339,7 +339,7 @@ class ThreadChannel extends Channel { * .catch(console.error); */ setArchived(archived = true, reason) { - return this.edit({ archived }, reason); + return this.edit({ archived, reason }); } /** @@ -357,7 +357,7 @@ class ThreadChannel extends Channel { * .catch(console.error); */ setAutoArchiveDuration(autoArchiveDuration, reason) { - return this.edit({ autoArchiveDuration }, reason); + return this.edit({ autoArchiveDuration, reason }); } /** @@ -371,7 +371,7 @@ class ThreadChannel extends Channel { if (this.type !== ChannelType.GuildPrivateThread) { return Promise.reject(new RangeError('THREAD_INVITABLE_TYPE', this.type)); } - return this.edit({ invitable }, reason); + return this.edit({ invitable, reason }); } /** @@ -387,7 +387,7 @@ class ThreadChannel extends Channel { * .catch(console.error); */ setLocked(locked = true, reason) { - return this.edit({ locked }, reason); + return this.edit({ locked, reason }); } /** @@ -402,7 +402,7 @@ class ThreadChannel extends Channel { * .catch(console.error); */ setName(name, reason) { - return this.edit({ name }, reason); + return this.edit({ name, reason }); } /** @@ -412,7 +412,7 @@ class ThreadChannel extends Channel { * @returns {Promise} */ setRateLimitPerUser(rateLimitPerUser, reason) { - return this.edit({ rateLimitPerUser }, reason); + return this.edit({ rateLimitPerUser, reason }); } /** diff --git a/packages/discord.js/src/structures/VoiceChannel.js b/packages/discord.js/src/structures/VoiceChannel.js index 1141d5931..df8268b34 100644 --- a/packages/discord.js/src/structures/VoiceChannel.js +++ b/packages/discord.js/src/structures/VoiceChannel.js @@ -97,7 +97,7 @@ class VoiceChannel extends BaseGuildVoiceChannel { * .catch(console.error); */ setBitrate(bitrate, reason) { - return this.edit({ bitrate }, reason); + return this.edit({ bitrate, reason }); } /** @@ -112,7 +112,7 @@ class VoiceChannel extends BaseGuildVoiceChannel { * .catch(console.error); */ setUserLimit(userLimit, reason) { - return this.edit({ userLimit }, reason); + return this.edit({ userLimit, reason }); } /** @@ -122,7 +122,7 @@ class VoiceChannel extends BaseGuildVoiceChannel { * @returns {Promise} */ setVideoQualityMode(videoQualityMode, reason) { - return this.edit({ videoQualityMode }, reason); + return this.edit({ videoQualityMode, reason }); } // These are here only for documentation purposes - they are implemented by TextBasedChannel diff --git a/packages/discord.js/src/structures/VoiceState.js b/packages/discord.js/src/structures/VoiceState.js index 52466ed8b..2cbff4e4a 100644 --- a/packages/discord.js/src/structures/VoiceState.js +++ b/packages/discord.js/src/structures/VoiceState.js @@ -172,7 +172,7 @@ class VoiceState extends Base { * @returns {Promise} */ setMute(mute = true, reason) { - return this.guild.members.edit(this.id, { mute }, reason); + return this.guild.members.edit(this.id, { mute, reason }); } /** @@ -182,7 +182,7 @@ class VoiceState extends Base { * @returns {Promise} */ setDeaf(deaf = true, reason) { - return this.guild.members.edit(this.id, { deaf }, reason); + return this.guild.members.edit(this.id, { deaf, reason }); } /** @@ -202,7 +202,7 @@ class VoiceState extends Base { * @returns {Promise} */ setChannel(channel, reason) { - return this.guild.members.edit(this.id, { channel }, reason); + return this.guild.members.edit(this.id, { channel, reason }); } /** diff --git a/packages/discord.js/src/structures/Webhook.js b/packages/discord.js/src/structures/Webhook.js index a208a3546..a19ee2571 100644 --- a/packages/discord.js/src/structures/Webhook.js +++ b/packages/discord.js/src/structures/Webhook.js @@ -249,15 +249,15 @@ class Webhook { * @property {string} [name=this.name] The new name for the webhook * @property {?(BufferResolvable)} [avatar] The new avatar for the webhook * @property {GuildTextChannelResolvable} [channel] The new channel for the webhook + * @property {string} [reason] Reason for editing the webhook */ /** * Edits this webhook. * @param {WebhookEditData} options Options for editing the webhook - * @param {string} [reason] Reason for editing the webhook * @returns {Promise} */ - async edit({ name = this.name, avatar, channel }, reason) { + async edit({ name = this.name, avatar, channel, reason }) { if (avatar && !(typeof avatar === 'string' && avatar.startsWith('data:'))) { avatar = await DataResolver.resolveImage(avatar); } diff --git a/packages/discord.js/src/structures/interfaces/TextBasedChannel.js b/packages/discord.js/src/structures/interfaces/TextBasedChannel.js index 2510ae054..3df53d3b4 100644 --- a/packages/discord.js/src/structures/interfaces/TextBasedChannel.js +++ b/packages/discord.js/src/structures/interfaces/TextBasedChannel.js @@ -345,13 +345,13 @@ class TextBasedChannel { /** * Options used to create a {@link Webhook} in a {@link TextChannel} or a {@link NewsChannel}. * @typedef {Object} ChannelWebhookCreateOptions + * @property {string} name The name of the webhook * @property {?(BufferResolvable|Base64Resolvable)} [avatar] Avatar for the webhook * @property {string} [reason] Reason for creating the webhook */ /** * Creates a webhook for the channel. - * @param {string} name The name of the webhook * @param {ChannelWebhookCreateOptions} [options] Options for creating the webhook * @returns {Promise} Returns the created Webhook * @example @@ -363,8 +363,8 @@ class TextBasedChannel { * .then(console.log) * .catch(console.error) */ - createWebhook(name, options = {}) { - return this.guild.channels.createWebhook(this.id, name, options); + createWebhook(options) { + return this.guild.channels.createWebhook({ channel: this.id, ...options }); } /** @@ -374,7 +374,7 @@ class TextBasedChannel { * @returns {Promise} */ setRateLimitPerUser(rateLimitPerUser, reason) { - return this.edit({ rateLimitPerUser }, reason); + return this.edit({ rateLimitPerUser, reason }); } /** @@ -384,7 +384,7 @@ class TextBasedChannel { * @returns {Promise} */ setNSFW(nsfw = true, reason) { - return this.edit({ nsfw }, reason); + return this.edit({ nsfw, reason }); } static applyToClass(structure, full = false, ignore = []) { diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 31721e263..43cda7d1a 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -1123,7 +1123,7 @@ export class Guild extends AnonymousGuild { public createTemplate(name: string, description?: string): Promise; public delete(): Promise; public discoverySplashURL(options?: ImageURLOptions): string | null; - public edit(data: GuildEditData, reason?: string): Promise; + public edit(data: GuildEditData): Promise; public editWelcomeScreen(data: WelcomeScreenEditData): Promise; public equals(guild: Guild): boolean; public fetchAuditLogs( @@ -1240,7 +1240,7 @@ export abstract class GuildChannel extends Channel { public get viewable(): boolean; public clone(options?: GuildChannelCloneOptions): Promise; public delete(reason?: string): Promise; - public edit(data: ChannelData, reason?: string): Promise; + public edit(data: ChannelEditData): Promise; public equals(channel: GuildChannel): boolean; public lockPermissions(): Promise; public permissionsFor(memberOrRole: GuildMember | Role, checkAdmin?: boolean): Readonly; @@ -1265,7 +1265,7 @@ export class GuildEmoji extends BaseGuildEmoji { public get roles(): GuildEmojiRoleManager; public get url(): string; public delete(reason?: string): Promise; - public edit(data: GuildEmojiEditData, reason?: string): Promise; + public edit(data: GuildEmojiEditData): Promise; public equals(other: GuildEmoji | unknown): boolean; public fetchAuthor(): Promise; public setName(name: string, reason?: string): Promise; @@ -1305,7 +1305,7 @@ export class GuildMember extends PartialTextBasedChannel(Base) { public createDM(force?: boolean): Promise; public deleteDM(): Promise; public displayAvatarURL(options?: ImageURLOptions): string; - public edit(data: GuildMemberEditData, reason?: string): Promise; + public edit(data: GuildMemberEditData): Promise; public isCommunicationDisabled(): this is GuildMember & { communicationDisabledUntilTimestamp: number; readonly communicationDisabledUntil: Date; @@ -2123,7 +2123,7 @@ export class Role extends Base { public icon: string | null; public unicodeEmoji: string | null; public delete(reason?: string): Promise; - public edit(data: RoleData, reason?: string): Promise; + public edit(data: EditRoleOptions): Promise; public equals(role: Role): boolean; public iconURL(options?: ImageURLOptions): string | null; public permissionsIn( @@ -2337,7 +2337,7 @@ export class Sticker extends Base { public fetch(): Promise; public fetchPack(): Promise; public fetchUser(): Promise; - public edit(data?: GuildStickerEditData, reason?: string): Promise; + public edit(data?: GuildStickerEditData): Promise; public delete(reason?: string): Promise; public equals(other: Sticker | unknown): boolean; } @@ -2502,7 +2502,7 @@ export class ThreadChannel extends TextBasedChannelMixin(Channel, ['fetchWebhook public type: ThreadChannelType; public get unarchivable(): boolean; public delete(reason?: string): Promise; - public edit(data: ThreadEditData, reason?: string): Promise; + public edit(data: ThreadEditData): Promise; public join(): Promise; public leave(): Promise; public permissionsFor(memberOrRole: GuildMember | Role, checkAdmin?: boolean): Readonly; @@ -3107,10 +3107,9 @@ export class CategoryChannelChildManager extends DataManager< public channel: CategoryChannel; public get guild(): Guild; public create( - name: string, options: CategoryCreateChannelOptions & { type: T }, ): Promise; - public create(name: string, options?: CategoryCreateChannelOptions): Promise; + public create(options: CategoryCreateChannelOptions): Promise; } export class ChannelManager extends CachedManager { @@ -3150,16 +3149,11 @@ export class GuildChannelManager extends CachedManager( - name: string, options: GuildChannelCreateOptions & { type: T }, ): Promise; - public create(name: string, options?: GuildChannelCreateOptions): Promise; - public createWebhook( - channel: GuildChannelResolvable, - name: string, - options?: ChannelWebhookCreateOptions, - ): Promise; - public edit(channel: GuildChannelResolvable, data: ChannelData, reason?: string): Promise; + public create(options: GuildChannelCreateOptions): Promise; + public createWebhook(options: WebhookCreateOptions): Promise; + public edit(channel: GuildChannelResolvable, data: ChannelEditData): Promise; public fetch(id: Snowflake, options?: BaseFetchOptions): Promise; public fetch(id?: undefined, options?: BaseFetchOptions): Promise>; public fetchWebhooks(channel: GuildChannelResolvable): Promise>; @@ -3176,16 +3170,12 @@ export class GuildChannelManager extends CachedManager); public guild: Guild; - public create( - attachment: BufferResolvable | Base64Resolvable, - name: string, - options?: GuildEmojiCreateOptions, - ): Promise; + public create(options: GuildEmojiCreateOptions): Promise; public fetch(id: Snowflake, options?: BaseFetchOptions): Promise; public fetch(id?: undefined, options?: BaseFetchOptions): Promise>; public fetchAuthor(emoji: EmojiResolvable): Promise; public delete(emoji: EmojiResolvable, reason?: string): Promise; - public edit(emoji: EmojiResolvable, data: GuildEmojiEditData, reason?: string): Promise; + public edit(emoji: EmojiResolvable, data: GuildEmojiEditData): Promise; } export class GuildEmojiRoleManager extends DataManager { @@ -3203,7 +3193,7 @@ export class GuildEmojiRoleManager extends DataManager { private constructor(client: Client, iterable?: Iterable); - public create(name: string, options?: GuildCreateOptions): Promise; + public create(options: GuildCreateOptions): Promise; public fetch(options: Snowflake | FetchGuildOptions): Promise; public fetch(options?: FetchGuildsOptions): Promise>; } @@ -3218,7 +3208,7 @@ export class GuildMemberManager extends CachedManager; public add(user: UserResolvable, options: AddGuildMemberOptions): Promise; public ban(user: UserResolvable, options?: BanOptions): Promise; - public edit(user: UserResolvable, data: GuildMemberEditData, reason?: string): Promise; + public edit(user: UserResolvable, data: GuildMemberEditData): Promise; public fetch( options: UserResolvable | FetchMemberOptions | (FetchMembersOptions & { user: UserResolvable }), ): Promise; @@ -3275,13 +3265,8 @@ export class GuildScheduledEventManager extends CachedManager< export class GuildStickerManager extends CachedManager { private constructor(guild: Guild, iterable?: Iterable); public guild: Guild; - public create( - file: BufferResolvable | Stream | AttachmentPayload | JSONEncodable, - name: string, - tags: string, - options?: GuildStickerCreateOptions, - ): Promise; - public edit(sticker: StickerResolvable, data?: GuildStickerEditData, reason?: string): Promise; + public create(options: GuildStickerCreateOptions): Promise; + public edit(sticker: StickerResolvable, data?: GuildStickerEditData): Promise; public delete(sticker: StickerResolvable, reason?: string): Promise; public fetch(id: Snowflake, options?: BaseFetchOptions): Promise; public fetch(id?: Snowflake, options?: BaseFetchOptions): Promise>; @@ -3380,7 +3365,7 @@ export class RoleManager extends CachedManager public fetch(id: Snowflake, options?: BaseFetchOptions): Promise; public fetch(id?: undefined, options?: BaseFetchOptions): Promise>; public create(options?: CreateRoleOptions): Promise; - public edit(role: RoleResolvable, options: RoleData, reason?: string): Promise; + public edit(role: RoleResolvable, options: EditRoleOptions): Promise; public delete(role: RoleResolvable, reason?: string): Promise; public setPosition(role: RoleResolvable, position: number, options?: SetRolePositionOptions): Promise; public setPositions(rolePositions: readonly RolePosition[]): Promise; @@ -3469,7 +3454,7 @@ export interface TextBasedChannelFields extends PartialTextBasedChannelFields { options?: MessageChannelCollectorOptionsParams, ): InteractionCollector; createMessageCollector(options?: MessageCollectorOptions): MessageCollector; - createWebhook(name: string, options?: ChannelWebhookCreateOptions): Promise; + createWebhook(options: ChannelWebhookCreateOptions): Promise; fetchWebhooks(): Promise>; sendTyping(): Promise; setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise; @@ -3495,7 +3480,7 @@ export interface WebhookFields extends PartialWebhookFields { get createdAt(): Date; get createdTimestamp(): number; delete(reason?: string): Promise; - edit(options: WebhookEditData, reason?: string): Promise; + edit(options: WebhookEditData): Promise; sendSlackMessage(body: unknown): Promise; } @@ -3809,6 +3794,7 @@ export type CacheWithLimitsOptions = { }; export interface CategoryCreateChannelOptions { + name: string; permissionOverwrites?: OverwriteResolvable[] | Collection; topic?: string; type?: CategoryChannelType; @@ -3845,6 +3831,10 @@ export interface ChannelData { videoQualityMode?: VideoQualityMode | null; } +export interface ChannelEditData extends ChannelData { + reason?: string; +} + export type ChannelMention = `<#${Snowflake}>`; export interface ChannelPosition { @@ -3858,10 +3848,15 @@ export type GuildTextChannelResolvable = TextChannel | NewsChannel | Snowflake; export type ChannelResolvable = AnyChannel | Snowflake; export interface ChannelWebhookCreateOptions { + name: string; avatar?: BufferResolvable | Base64Resolvable | null; reason?: string; } +export interface WebhookCreateOptions extends ChannelWebhookCreateOptions { + channel: GuildChannelResolvable; +} + export interface ClientEvents { cacheSweep: [message: string]; channelCreate: [channel: NonThreadGuildBasedChannel]; @@ -4166,6 +4161,10 @@ export interface CreateRoleOptions extends RoleData { reason?: string; } +export interface EditRoleOptions extends RoleData { + reason?: string; +} + export interface StageInstanceCreateOptions { topic: string; privacyLevel?: StageInstancePrivacyLevel; @@ -4471,7 +4470,7 @@ export interface GuildChannelCreateOptions extends Omit; } -export interface GuildChannelCloneOptions extends GuildChannelCreateOptions { +export interface GuildChannelCloneOptions extends Omit { name?: string; } @@ -4481,6 +4480,7 @@ export interface GuildChannelOverwriteOptions { } export interface GuildCreateOptions { + name: string; afkChannelId?: Snowflake | number; afkTimeout?: number; channels?: PartialChannelData[]; @@ -4518,9 +4518,12 @@ export interface GuildEditData { premiumProgressBarEnabled?: boolean; description?: string | null; features?: GuildFeature[]; + reason?: string; } export interface GuildEmojiCreateOptions { + attachment: BufferResolvable | Base64Resolvable; + name: string; roles?: Collection | RoleResolvable[]; reason?: string; } @@ -4528,9 +4531,13 @@ export interface GuildEmojiCreateOptions { export interface GuildEmojiEditData { name?: string; roles?: Collection | RoleResolvable[]; + reason?: string; } export interface GuildStickerCreateOptions { + file: BufferResolvable | Stream | AttachmentPayload | JSONEncodable; + name: string; + tags: string; description?: string | null; reason?: string; } @@ -4539,6 +4546,7 @@ export interface GuildStickerEditData { name?: string; description?: string | null; tags?: string; + reason?: string; } export interface GuildMemberEditData { @@ -4548,6 +4556,7 @@ export interface GuildMemberEditData { deaf?: boolean; channel?: GuildVoiceChannelResolvable | null; communicationDisabledUntil?: DateResolvable | null; + reason?: string; } export type GuildMemberResolvable = GuildMember | UserResolvable; @@ -5218,6 +5227,7 @@ export interface ThreadEditData { rateLimitPerUser?: number; locked?: boolean; invitable?: boolean; + reason?: string; } export type ThreadMemberResolvable = ThreadMember | UserResolvable; @@ -5257,6 +5267,7 @@ export interface WebhookEditData { name?: string; avatar?: BufferResolvable | null; channel?: GuildTextChannelResolvable; + reason?: string; } export type WebhookEditMessageOptions = Pick< diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index b8757d548..743f0b35f 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -1035,25 +1035,27 @@ expectType>(guildApplicationCommandManager.fetch('0' declare const categoryChannelChildManager: CategoryChannelChildManager; { - expectType>(categoryChannelChildManager.create('name', { type: ChannelType.GuildVoice })); - expectType>(categoryChannelChildManager.create('name', { type: ChannelType.GuildText })); - expectType>(categoryChannelChildManager.create('name', { type: ChannelType.GuildNews })); - expectType>(categoryChannelChildManager.create('name', { type: ChannelType.GuildStageVoice })); - expectType>(categoryChannelChildManager.create('name', {})); - expectType>(categoryChannelChildManager.create('name')); + expectType>(categoryChannelChildManager.create({ name: 'name', type: ChannelType.GuildVoice })); + expectType>(categoryChannelChildManager.create({ name: 'name', type: ChannelType.GuildText })); + expectType>(categoryChannelChildManager.create({ name: 'name', type: ChannelType.GuildNews })); + expectType>( + categoryChannelChildManager.create({ name: 'name', type: ChannelType.GuildStageVoice }), + ); + expectType>(categoryChannelChildManager.create({ name: 'name' })); + expectType>(categoryChannelChildManager.create({ name: 'name' })); } declare const guildChannelManager: GuildChannelManager; { type AnyChannel = TextChannel | VoiceChannel | CategoryChannel | NewsChannel | StageChannel; - expectType>(guildChannelManager.create('name')); - expectType>(guildChannelManager.create('name', {})); - expectType>(guildChannelManager.create('name', { type: ChannelType.GuildVoice })); - expectType>(guildChannelManager.create('name', { type: ChannelType.GuildCategory })); - expectType>(guildChannelManager.create('name', { type: ChannelType.GuildText })); - expectType>(guildChannelManager.create('name', { type: ChannelType.GuildNews })); - expectType>(guildChannelManager.create('name', { type: ChannelType.GuildStageVoice })); + expectType>(guildChannelManager.create({ name: 'name' })); + expectType>(guildChannelManager.create({ name: 'name' })); + expectType>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildVoice })); + expectType>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildCategory })); + expectType>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildText })); + expectType>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildNews })); + expectType>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildStageVoice })); expectType>>(guildChannelManager.fetch()); expectType>>(guildChannelManager.fetch(undefined, {}));