refactor(*): include name/reason/etc fields into options/data params (#8026)

This commit is contained in:
DD
2022-06-10 22:20:59 +03:00
committed by GitHub
parent 2392a6f5de
commit 9c8b3102ce
25 changed files with 238 additions and 225 deletions

View File

@@ -38,6 +38,7 @@ class CategoryChannelChildManager extends DataManager {
/** /**
* Options for creating a channel using {@link CategoryChannel#createChannel}. * Options for creating a channel using {@link CategoryChannel#createChannel}.
* @typedef {Object} CategoryCreateChannelOptions * @typedef {Object} CategoryCreateChannelOptions
* @property {string} name The name for the new channel
* @property {ChannelType} [type=ChannelType.GuildText] The type of the new channel. * @property {ChannelType} [type=ChannelType.GuildText] The type of the new channel.
* @property {string} [topic] The topic for the new channel * @property {string} [topic] The topic for the new channel
* @property {boolean} [nsfw] Whether the new channel is NSFW * @property {boolean} [nsfw] Whether the new channel is NSFW
@@ -55,12 +56,11 @@ class CategoryChannelChildManager extends DataManager {
/** /**
* Creates a new channel within this category. * Creates a new channel within this category.
* <info>You cannot create a channel of type {@link ChannelType.GuildCategory} inside a CategoryChannel.</info> * <info>You cannot create a channel of type {@link ChannelType.GuildCategory} inside a CategoryChannel.</info>
* @param {string} name The name of the new channel
* @param {CategoryCreateChannelOptions} options Options for creating the new channel * @param {CategoryCreateChannelOptions} options Options for creating the new channel
* @returns {Promise<GuildChannel>} * @returns {Promise<GuildChannel>}
*/ */
create(name, options) { create(options) {
return this.guild.channels.create(name, { return this.guild.channels.create({
...options, ...options,
parent: this.channel.id, parent: this.channel.id,
}); });

View File

@@ -104,17 +104,17 @@ class GuildChannelManager extends CachedManager {
/** /**
* Creates a new channel in the guild. * 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<GuildChannel>} * @returns {Promise<GuildChannel>}
* @example * @example
* // Create a new text channel * // 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) * .then(console.log)
* .catch(console.error); * .catch(console.error);
* @example * @example
* // Create a new channel with permission overwrites * // Create a new channel with permission overwrites
* guild.channels.create('new-voice', { * guild.channels.create({
* name: 'new-general',
* type: ChannelType.GuildVoice, * type: ChannelType.GuildVoice,
* permissionOverwrites: [ * permissionOverwrites: [
* { * {
@@ -124,23 +124,21 @@ class GuildChannelManager extends CachedManager {
* ], * ],
* }) * })
*/ */
async create( async create({
name, name,
{ type,
type, topic,
topic, nsfw,
nsfw, bitrate,
bitrate, userLimit,
userLimit, parent,
parent, permissionOverwrites,
permissionOverwrites, position,
position, rateLimitPerUser,
rateLimitPerUser, rtcRegion,
rtcRegion, videoQualityMode,
videoQualityMode, reason,
reason, }) {
} = {},
) {
parent &&= this.client.channels.resolveId(parent); parent &&= this.client.channels.resolveId(parent);
permissionOverwrites &&= permissionOverwrites.map(o => PermissionOverwrites.resolve(o, this.guild)); 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; 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. * Creates a webhook for the channel.
* @param {GuildChannelResolvable} channel The channel to create the webhook for * @param {WebhookCreateOptions} options Options for creating the webhook
* @param {string} name The name of the webhook
* @param {ChannelWebhookCreateOptions} [options] Options for creating the webhook
* @returns {Promise<Webhook>} Returns the created Webhook * @returns {Promise<Webhook>} Returns the created Webhook
* @example * @example
* // Create a webhook for the current channel * // 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', * avatar: 'https://i.imgur.com/mI8XcpG.jpg',
* reason: 'Needed a cool new Webhook' * reason: 'Needed a cool new Webhook'
* }) * })
* .then(console.log) * .then(console.log)
* .catch(console.error) * .catch(console.error)
*/ */
async createWebhook(channel, name, { avatar, reason } = {}) { async createWebhook({ channel, name, avatar, reason }) {
const id = this.resolveId(channel); const id = this.resolveId(channel);
if (!id) throw new TypeError('INVALID_TYPE', 'channel', 'GuildChannelResolvable'); if (!id) throw new TypeError('INVALID_TYPE', 'channel', 'GuildChannelResolvable');
if (typeof avatar === 'string' && !avatar.startsWith('data:')) { 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 * The default auto archive duration for all new threads in this channel
* @property {?string} [rtcRegion] The RTC region of the channel * @property {?string} [rtcRegion] The RTC region of the channel
* @property {?VideoQualityMode} [videoQualityMode] The camera video quality mode 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. * Edits the channel.
* @param {GuildChannelResolvable} channel The channel to edit * @param {GuildChannelResolvable} channel The channel to edit
* @param {ChannelData} data The new data for the channel * @param {ChannelData} data The new data for the channel
* @param {string} [reason] Reason for editing this channel
* @returns {Promise<GuildChannel>} * @returns {Promise<GuildChannel>}
* @example * @example
* // Edit a channel * // Edit a channel
@@ -229,13 +232,15 @@ class GuildChannelManager extends CachedManager {
* .then(console.log) * .then(console.log)
* .catch(console.error); * .catch(console.error);
*/ */
async edit(channel, data, reason) { async edit(channel, data) {
channel = this.resolve(channel); channel = this.resolve(channel);
if (!channel) throw new TypeError('INVALID_TYPE', 'channel', 'GuildChannelResolvable'); if (!channel) throw new TypeError('INVALID_TYPE', 'channel', 'GuildChannelResolvable');
const parent = data.parent && this.client.channels.resolveId(data.parent); 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)); 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, default_auto_archive_duration: data.defaultAutoArchiveDuration,
permission_overwrites, permission_overwrites,
}, },
reason, reason: data.reason,
}); });
return this.client.actions.ChannelUpdate.handle(newData).updated; return this.client.actions.ChannelUpdate.handle(newData).updated;
@@ -280,7 +285,7 @@ class GuildChannelManager extends CachedManager {
* Sets a new position for the guild channel. * Sets a new position for the guild channel.
* @param {GuildChannelResolvable} channel The channel to set the position for * @param {GuildChannelResolvable} channel The channel to set the position for
* @param {number} position The new position for the guild channel * @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<GuildChannel>} * @returns {Promise<GuildChannel>}
* @example * @example
* // Set a new channel position * // Set a new channel position

View File

@@ -27,29 +27,29 @@ class GuildEmojiManager extends BaseGuildEmojiManager {
/** /**
* Options used for creating an emoji in a guild. * 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<Snowflake, Role>|RoleResolvable[]} [roles] The roles to limit the emoji to * @property {Collection<Snowflake, Role>|RoleResolvable[]} [roles] The roles to limit the emoji to
* @property {string} [reason] The reason for creating the emoji * @property {string} [reason] The reason for creating the emoji
*/ */
/** /**
* Creates a new custom emoji in the guild. * Creates a new custom emoji in the guild.
* @param {BufferResolvable|Base64Resolvable} attachment The image for the emoji * @param {GuildEmojiCreateOptions} options Options for creating the emoji
* @param {string} name The name for the emoji
* @param {GuildEmojiCreateOptions} [options] Options for creating the emoji
* @returns {Promise<Emoji>} The created emoji * @returns {Promise<Emoji>} The created emoji
* @example * @example
* // Create a new emoji from a URL * // 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}!`)) * .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`))
* .catch(console.error); * .catch(console.error);
* @example * @example
* // Create a new emoji from a file on your computer * // 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}!`)) * .then(emoji => console.log(`Created new emoji with name ${emoji.name}!`))
* .catch(console.error); * .catch(console.error);
*/ */
async create(attachment, name, { roles, reason } = {}) { async create({ attachment, name, roles, reason }) {
attachment = await DataResolver.resolveImage(attachment); attachment = await DataResolver.resolveImage(attachment);
if (!attachment) throw new TypeError('REQ_RESOURCE_TYPE'); if (!attachment) throw new TypeError('REQ_RESOURCE_TYPE');
@@ -118,10 +118,9 @@ class GuildEmojiManager extends BaseGuildEmojiManager {
* Edits an emoji. * Edits an emoji.
* @param {EmojiResolvable} emoji The Emoji resolvable to edit * @param {EmojiResolvable} emoji The Emoji resolvable to edit
* @param {GuildEmojiEditData} data The new data for the emoji * @param {GuildEmojiEditData} data The new data for the emoji
* @param {string} [reason] Reason for editing this emoji
* @returns {Promise<GuildEmoji>} * @returns {Promise<GuildEmoji>}
*/ */
async edit(emoji, data, reason) { async edit(emoji, data) {
const id = this.resolveId(emoji); const id = this.resolveId(emoji);
if (!id) throw new TypeError('INVALID_TYPE', 'emoji', 'EmojiResolvable', true); if (!id) throw new TypeError('INVALID_TYPE', 'emoji', 'EmojiResolvable', true);
const roles = data.roles?.map(r => this.guild.roles.resolveId(r)); const roles = data.roles?.map(r => this.guild.roles.resolveId(r));
@@ -130,7 +129,7 @@ class GuildEmojiManager extends BaseGuildEmojiManager {
name: data.name, name: data.name,
roles, roles,
}, },
reason, reason: data.reason,
}); });
const existing = this.cache.get(id); const existing = this.cache.get(id);
if (existing) { if (existing) {

View File

@@ -141,6 +141,7 @@ class GuildManager extends CachedManager {
/** /**
* Options used to create a guild. * Options used to create a guild.
* @typedef {Object} GuildCreateOptions * @typedef {Object} GuildCreateOptions
* @property {string} name The name of the guild
* @property {Snowflake|number} [afkChannelId] The AFK channel's id * @property {Snowflake|number} [afkChannelId] The AFK channel's id
* @property {number} [afkTimeout] The AFK timeout in seconds * @property {number} [afkTimeout] The AFK timeout in seconds
* @property {PartialChannelData[]} [channels=[]] The channels for this guild * @property {PartialChannelData[]} [channels=[]] The channels for this guild
@@ -159,25 +160,22 @@ class GuildManager extends CachedManager {
/** /**
* Creates a guild. * Creates a guild.
* <warn>This is only available to bots in fewer than 10 guilds.</warn> * <warn>This is only available to bots in fewer than 10 guilds.</warn>
* @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<Guild>} The guild that was created * @returns {Promise<Guild>} The guild that was created
*/ */
async create( async create({
name, name,
{ afkChannelId,
afkChannelId, afkTimeout,
afkTimeout, channels = [],
channels = [], defaultMessageNotifications,
defaultMessageNotifications, explicitContentFilter,
explicitContentFilter, icon = null,
icon = null, roles = [],
roles = [], systemChannelId,
systemChannelId, systemChannelFlags,
systemChannelFlags, verificationLevel,
verificationLevel, }) {
} = {},
) {
icon = await DataResolver.resolveImage(icon); icon = await DataResolver.resolveImage(icon);
for (const channel of channels) { for (const channel of channels) {

View File

@@ -265,6 +265,7 @@ class GuildMemberManager extends CachedManager {
* (if they are connected to voice), or `null` if you want to disconnect them from voice * (if they are connected to voice), or `null` if you want to disconnect them from voice
* @property {DateResolvable|null} [communicationDisabledUntil] The date or timestamp * @property {DateResolvable|null} [communicationDisabledUntil] The date or timestamp
* for the member's communication to be disabled until. Provide `null` to enable communication again. * 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 {
* <info>The user must be a member of the guild</info> * <info>The user must be a member of the guild</info>
* @param {UserResolvable} user The member to edit * @param {UserResolvable} user The member to edit
* @param {GuildMemberEditData} data The data to edit the member with * @param {GuildMemberEditData} data The data to edit the member with
* @param {string} [reason] Reason for editing this user
* @returns {Promise<GuildMember>} * @returns {Promise<GuildMember>}
*/ */
async edit(user, data, reason) { async edit(user, { reason, ...data }) {
const id = this.client.users.resolveId(user); const id = this.client.users.resolveId(user);
if (!id) throw new TypeError('INVALID_TYPE', 'user', 'UserResolvable'); if (!id) throw new TypeError('INVALID_TYPE', 'user', 'UserResolvable');
// Clone the data object for immutability if (data.channel) {
const _data = { ...data }; data.channel = this.guild.channels.resolve(data.channel);
if (_data.channel) { if (!(data.channel instanceof BaseGuildVoiceChannel)) {
_data.channel = this.guild.channels.resolve(_data.channel);
if (!(_data.channel instanceof BaseGuildVoiceChannel)) {
throw new Error('GUILD_VOICE_CHANNEL_RESOLVE'); throw new Error('GUILD_VOICE_CHANNEL_RESOLVE');
} }
_data.channel_id = _data.channel.id; data.channel_id = data.channel.id;
_data.channel = undefined; data.channel = undefined;
} else if (_data.channel === null) { } else if (data.channel === null) {
_data.channel_id = null; data.channel_id = null;
_data.channel = undefined; 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 // eslint-disable-next-line eqeqeq
_data.communicationDisabledUntil != null data.communicationDisabledUntil != null
? new Date(_data.communicationDisabledUntil).toISOString() ? new Date(data.communicationDisabledUntil).toISOString()
: _data.communicationDisabledUntil; : data.communicationDisabledUntil;
let endpoint; let endpoint;
if (id === this.client.user.id) { if (id === this.client.user.id) {
@@ -308,7 +306,7 @@ class GuildMemberManager extends CachedManager {
} else { } else {
endpoint = Routes.guildMember(this.guild.id, id); 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(); const clone = this.cache.get(id)?._clone();
clone?._patch(d); clone?._patch(d);

View File

@@ -179,7 +179,7 @@ class GuildMemberRoleManager extends DataManager {
* .catch(console.error); * .catch(console.error);
*/ */
set(roles, reason) { set(roles, reason) {
return this.member.edit({ roles }, reason); return this.member.edit({ roles, reason });
} }
clone() { clone() {

View File

@@ -35,16 +35,16 @@ class GuildStickerManager extends CachedManager {
/** /**
* Options for creating a guild sticker. * Options for creating a guild sticker.
* @typedef {Object} GuildStickerCreateOptions * @typedef {Object} GuildStickerCreateOptions
* @property {BufferResolvable|Stream|JSONEncodable<AttachmentPayload>} 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} [description] The description for the sticker
* @property {string} [reason] Reason for creating the sticker * @property {string} [reason] Reason for creating the sticker
*/ */
/** /**
* Creates a new custom sticker in the guild. * Creates a new custom sticker in the guild.
* @param {BufferResolvable|Stream|JSONEncodable<AttachmentPayload>} file The file for the sticker * @param {GuildStickerCreateOptions} options Options
* @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
* @returns {Promise<Sticker>} The created sticker * @returns {Promise<Sticker>} The created sticker
* @example * @example
* // Create a new sticker from a URL * // 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}!`)) * .then(sticker => console.log(`Created new sticker with name ${sticker.name}!`))
* .catch(console.error); * .catch(console.error);
*/ */
async create(file, name, tags, { description, reason } = {}) { async create({ file, name, tags, description, reason } = {}) {
const resolvedFile = await MessagePayload.resolveFile(file); const resolvedFile = await MessagePayload.resolveFile(file);
if (!resolvedFile) throw new TypeError('REQ_RESOURCE_TYPE'); if (!resolvedFile) throw new TypeError('REQ_RESOURCE_TYPE');
file = { ...resolvedFile, key: 'file' }; file = { ...resolvedFile, key: 'file' };
@@ -101,17 +101,16 @@ class GuildStickerManager extends CachedManager {
/** /**
* Edits a sticker. * Edits a sticker.
* @param {StickerResolvable} sticker The sticker to edit * @param {StickerResolvable} sticker The sticker to edit
* @param {GuildStickerEditData} [data] The new data for the sticker * @param {GuildStickerEditData} [data={}] The new data for the sticker
* @param {string} [reason] Reason for editing this sticker
* @returns {Promise<Sticker>} * @returns {Promise<Sticker>}
*/ */
async edit(sticker, data, reason) { async edit(sticker, data = {}) {
const stickerId = this.resolveId(sticker); const stickerId = this.resolveId(sticker);
if (!stickerId) throw new TypeError('INVALID_TYPE', 'sticker', 'StickerResolvable'); if (!stickerId) throw new TypeError('INVALID_TYPE', 'sticker', 'StickerResolvable');
const d = await this.client.rest.patch(Routes.guildSticker(this.guild.id, stickerId), { const d = await this.client.rest.patch(Routes.guildSticker(this.guild.id, stickerId), {
body: data, body: data,
reason, reason: data.reason,
}); });
const existing = this.cache.get(stickerId); const existing = this.cache.get(stickerId);

View File

@@ -165,11 +165,16 @@ class RoleManager extends CachedManager {
return role; 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. * Edits a role of the guild.
* @param {RoleResolvable} role The role to edit * @param {RoleResolvable} role The role to edit
* @param {RoleData} data The new data for the role * @param {EditRoleOptions} data The new data for the role
* @param {string} [reason] Reason for editing this role
* @returns {Promise<Role>} * @returns {Promise<Role>}
* @example * @example
* // Edit a role * // Edit a role
@@ -177,12 +182,12 @@ class RoleManager extends CachedManager {
* .then(updated => console.log(`Edited role name to ${updated.name}`)) * .then(updated => console.log(`Edited role name to ${updated.name}`))
* .catch(console.error); * .catch(console.error);
*/ */
async edit(role, data, reason) { async edit(role, data) {
role = this.resolve(role); role = this.resolve(role);
if (!role) throw new TypeError('INVALID_TYPE', 'role', 'RoleResolvable'); if (!role) throw new TypeError('INVALID_TYPE', 'role', 'RoleResolvable');
if (typeof data.position === 'number') { 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; let icon = data.icon;
@@ -202,7 +207,7 @@ class RoleManager extends CachedManager {
unicode_emoji: data.unicodeEmoji, 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(); const clone = role._clone();
clone._patch(d); clone._patch(d);

View File

@@ -86,7 +86,7 @@ class BaseGuildTextChannel extends GuildChannel {
* @returns {Promise<TextChannel>} * @returns {Promise<TextChannel>}
*/ */
setDefaultAutoArchiveDuration(defaultAutoArchiveDuration, reason) { setDefaultAutoArchiveDuration(defaultAutoArchiveDuration, reason) {
return this.edit({ defaultAutoArchiveDuration }, reason); return this.edit({ defaultAutoArchiveDuration, reason });
} }
/** /**
@@ -96,7 +96,7 @@ class BaseGuildTextChannel extends GuildChannel {
* @returns {Promise<GuildChannel>} * @returns {Promise<GuildChannel>}
*/ */
setType(type, reason) { setType(type, reason) {
return this.edit({ type }, reason); return this.edit({ type, reason });
} }
/** /**
@@ -111,7 +111,7 @@ class BaseGuildTextChannel extends GuildChannel {
* .catch(console.error); * .catch(console.error);
*/ */
setTopic(topic, reason) { setTopic(topic, reason) {
return this.edit({ topic }, reason); return this.edit({ topic, reason });
} }
/** /**

View File

@@ -93,7 +93,7 @@ class BaseGuildVoiceChannel extends GuildChannel {
* channel.setRTCRegion(null, 'We want to let Discord decide.'); * channel.setRTCRegion(null, 'We want to let Discord decide.');
*/ */
setRTCRegion(rtcRegion, reason) { setRTCRegion(rtcRegion, reason) {
return this.edit({ rtcRegion }, reason); return this.edit({ rtcRegion, reason });
} }
/** /**

View File

@@ -737,6 +737,7 @@ class Guild extends AnonymousGuild {
* @property {boolean} [premiumProgressBarEnabled] Whether the guild's premium progress bar is enabled * @property {boolean} [premiumProgressBarEnabled] Whether the guild's premium progress bar is enabled
* @property {?string} [description] The discovery description of the guild * @property {?string} [description] The discovery description of the guild
* @property {GuildFeature[]} [features] The features of the guild * @property {GuildFeature[]} [features] The features of the guild
* @property {string} [reason] Reason for editing this guild
*/ */
/* eslint-enable max-len */ /* eslint-enable max-len */
@@ -757,7 +758,6 @@ class Guild extends AnonymousGuild {
/** /**
* Updates the guild with new information - e.g. a new name. * Updates the guild with new information - e.g. a new name.
* @param {GuildEditData} data The data to update the guild with * @param {GuildEditData} data The data to update the guild with
* @param {string} [reason] Reason for editing this guild
* @returns {Promise<Guild>} * @returns {Promise<Guild>}
* @example * @example
* // Set the guild name * // Set the guild name
@@ -767,7 +767,7 @@ class Guild extends AnonymousGuild {
* .then(updated => console.log(`New guild name ${updated}`)) * .then(updated => console.log(`New guild name ${updated}`))
* .catch(console.error); * .catch(console.error);
*/ */
async edit(data, reason) { async edit(data) {
const _data = {}; const _data = {};
if (data.name) _data.name = data.name; if (data.name) _data.name = data.name;
if (typeof data.verificationLevel !== 'undefined') { if (typeof data.verificationLevel !== 'undefined') {
@@ -810,7 +810,7 @@ class Guild extends AnonymousGuild {
} }
if (typeof data.preferredLocale !== 'undefined') _data.preferred_locale = data.preferredLocale; if (typeof data.preferredLocale !== 'undefined') _data.preferred_locale = data.preferredLocale;
if ('premiumProgressBarEnabled' in data) _data.premium_progress_bar_enabled = data.premiumProgressBarEnabled; 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; return this.client.actions.GuildUpdate.handle(newData).updated;
} }
@@ -892,7 +892,7 @@ class Guild extends AnonymousGuild {
* @returns {Promise<Guild>} * @returns {Promise<Guild>}
*/ */
setExplicitContentFilter(explicitContentFilter, reason) { setExplicitContentFilter(explicitContentFilter, reason) {
return this.edit({ explicitContentFilter }, reason); return this.edit({ explicitContentFilter, reason });
} }
/** /**
@@ -902,7 +902,7 @@ class Guild extends AnonymousGuild {
* @returns {Promise<Guild>} * @returns {Promise<Guild>}
*/ */
setDefaultMessageNotifications(defaultMessageNotifications, reason) { setDefaultMessageNotifications(defaultMessageNotifications, reason) {
return this.edit({ defaultMessageNotifications }, reason); return this.edit({ defaultMessageNotifications, reason });
} }
/* eslint-enable max-len */ /* eslint-enable max-len */
@@ -913,7 +913,7 @@ class Guild extends AnonymousGuild {
* @returns {Promise<Guild>} * @returns {Promise<Guild>}
*/ */
setSystemChannelFlags(systemChannelFlags, reason) { setSystemChannelFlags(systemChannelFlags, reason) {
return this.edit({ systemChannelFlags }, reason); return this.edit({ systemChannelFlags, reason });
} }
/** /**
@@ -928,7 +928,7 @@ class Guild extends AnonymousGuild {
* .catch(console.error); * .catch(console.error);
*/ */
setName(name, reason) { setName(name, reason) {
return this.edit({ name }, reason); return this.edit({ name, reason });
} }
/** /**
@@ -943,7 +943,7 @@ class Guild extends AnonymousGuild {
* .catch(console.error); * .catch(console.error);
*/ */
setVerificationLevel(verificationLevel, reason) { setVerificationLevel(verificationLevel, reason) {
return this.edit({ verificationLevel }, reason); return this.edit({ verificationLevel, reason });
} }
/** /**
@@ -958,7 +958,7 @@ class Guild extends AnonymousGuild {
* .catch(console.error); * .catch(console.error);
*/ */
setAFKChannel(afkChannel, reason) { setAFKChannel(afkChannel, reason) {
return this.edit({ afkChannel }, reason); return this.edit({ afkChannel, reason });
} }
/** /**
@@ -973,7 +973,7 @@ class Guild extends AnonymousGuild {
* .catch(console.error); * .catch(console.error);
*/ */
setSystemChannel(systemChannel, reason) { setSystemChannel(systemChannel, reason) {
return this.edit({ systemChannel }, reason); return this.edit({ systemChannel, reason });
} }
/** /**
@@ -988,7 +988,7 @@ class Guild extends AnonymousGuild {
* .catch(console.error); * .catch(console.error);
*/ */
setAFKTimeout(afkTimeout, reason) { setAFKTimeout(afkTimeout, reason) {
return this.edit({ afkTimeout }, reason); return this.edit({ afkTimeout, reason });
} }
/** /**
@@ -1003,7 +1003,7 @@ class Guild extends AnonymousGuild {
* .catch(console.error); * .catch(console.error);
*/ */
setIcon(icon, reason) { setIcon(icon, reason) {
return this.edit({ icon }, reason); return this.edit({ icon, reason });
} }
/** /**
@@ -1019,7 +1019,7 @@ class Guild extends AnonymousGuild {
* .catch(console.error); * .catch(console.error);
*/ */
setOwner(owner, reason) { setOwner(owner, reason) {
return this.edit({ owner }, reason); return this.edit({ owner, reason });
} }
/** /**
@@ -1034,7 +1034,7 @@ class Guild extends AnonymousGuild {
* .catch(console.error); * .catch(console.error);
*/ */
setSplash(splash, reason) { setSplash(splash, reason) {
return this.edit({ splash }, reason); return this.edit({ splash, reason });
} }
/** /**
@@ -1049,7 +1049,7 @@ class Guild extends AnonymousGuild {
* .catch(console.error); * .catch(console.error);
*/ */
setDiscoverySplash(discoverySplash, reason) { setDiscoverySplash(discoverySplash, reason) {
return this.edit({ discoverySplash }, reason); return this.edit({ discoverySplash, reason });
} }
/** /**
@@ -1063,7 +1063,7 @@ class Guild extends AnonymousGuild {
* .catch(console.error); * .catch(console.error);
*/ */
setBanner(banner, reason) { setBanner(banner, reason) {
return this.edit({ banner }, reason); return this.edit({ banner, reason });
} }
/** /**
@@ -1078,7 +1078,7 @@ class Guild extends AnonymousGuild {
* .catch(console.error); * .catch(console.error);
*/ */
setRulesChannel(rulesChannel, reason) { setRulesChannel(rulesChannel, reason) {
return this.edit({ rulesChannel }, reason); return this.edit({ rulesChannel, reason });
} }
/** /**
@@ -1093,7 +1093,7 @@ class Guild extends AnonymousGuild {
* .catch(console.error); * .catch(console.error);
*/ */
setPublicUpdatesChannel(publicUpdatesChannel, reason) { setPublicUpdatesChannel(publicUpdatesChannel, reason) {
return this.edit({ publicUpdatesChannel }, reason); return this.edit({ publicUpdatesChannel, reason });
} }
/** /**
@@ -1108,7 +1108,7 @@ class Guild extends AnonymousGuild {
* .catch(console.error); * .catch(console.error);
*/ */
setPreferredLocale(preferredLocale, reason) { setPreferredLocale(preferredLocale, reason) {
return this.edit({ preferredLocale }, reason); return this.edit({ preferredLocale, reason });
} }
/** /**
@@ -1118,7 +1118,7 @@ class Guild extends AnonymousGuild {
* @returns {Promise<Guild>} * @returns {Promise<Guild>}
*/ */
setPremiumProgressBarEnabled(enabled = true, reason) { setPremiumProgressBarEnabled(enabled = true, reason) {
return this.edit({ premiumProgressBarEnabled: enabled }, reason); return this.edit({ premiumProgressBarEnabled: enabled, reason });
} }
/** /**

View File

@@ -264,8 +264,7 @@ class GuildChannel extends Channel {
/** /**
* Edits the channel. * Edits the channel.
* @param {ChannelData} data The new data for the channel * @param {ChannelEditData} data The new data for the channel
* @param {string} [reason] Reason for editing this channel
* @returns {Promise<GuildChannel>} * @returns {Promise<GuildChannel>}
* @example * @example
* // Edit a channel * // Edit a channel
@@ -273,8 +272,8 @@ class GuildChannel extends Channel {
* .then(console.log) * .then(console.log)
* .catch(console.error); * .catch(console.error);
*/ */
edit(data, reason) { edit(data) {
return this.guild.channels.edit(this, data, reason); return this.guild.channels.edit(this, data);
} }
/** /**
@@ -289,7 +288,7 @@ class GuildChannel extends Channel {
* .catch(console.error); * .catch(console.error);
*/ */
setName(name, reason) { setName(name, reason) {
return this.edit({ name }, reason); return this.edit({ name, reason });
} }
/** /**
@@ -311,13 +310,11 @@ class GuildChannel extends Channel {
* .catch(console.error); * .catch(console.error);
*/ */
setParent(channel, { lockPermissions = true, reason } = {}) { setParent(channel, { lockPermissions = true, reason } = {}) {
return this.edit( return this.edit({
{ parent: channel ?? null,
parent: channel ?? null, lockPermissions,
lockPermissions,
},
reason, reason,
); });
} }
/** /**
@@ -354,7 +351,8 @@ class GuildChannel extends Channel {
* @returns {Promise<GuildChannel>} * @returns {Promise<GuildChannel>}
*/ */
clone(options = {}) { 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, permissionOverwrites: this.permissionOverwrites.cache,
topic: this.topic, topic: this.topic,
type: this.type, type: this.type,

View File

@@ -81,12 +81,12 @@ class GuildEmoji extends BaseGuildEmoji {
* @typedef {Object} GuildEmojiEditData * @typedef {Object} GuildEmojiEditData
* @property {string} [name] The name of the emoji * @property {string} [name] The name of the emoji
* @property {Collection<Snowflake, Role>|RoleResolvable[]} [roles] Roles to restrict emoji to * @property {Collection<Snowflake, Role>|RoleResolvable[]} [roles] Roles to restrict emoji to
* @property {string} [reason] Reason for editing this emoji
*/ */
/** /**
* Edits the emoji. * Edits the emoji.
* @param {GuildEmojiEditData} data The new data for the emoji * @param {GuildEmojiEditData} data The new data for the emoji
* @param {string} [reason] Reason for editing this emoji
* @returns {Promise<GuildEmoji>} * @returns {Promise<GuildEmoji>}
* @example * @example
* // Edit an emoji * // Edit an emoji
@@ -94,8 +94,8 @@ class GuildEmoji extends BaseGuildEmoji {
* .then(e => console.log(`Edited emoji ${e}`)) * .then(e => console.log(`Edited emoji ${e}`))
* .catch(console.error); * .catch(console.error);
*/ */
edit(data, reason) { edit(data) {
return this.guild.emojis.edit(this.id, data, reason); return this.guild.emojis.edit(this.id, data);
} }
/** /**
@@ -105,7 +105,7 @@ class GuildEmoji extends BaseGuildEmoji {
* @returns {Promise<GuildEmoji>} * @returns {Promise<GuildEmoji>}
*/ */
setName(name, reason) { setName(name, reason) {
return this.edit({ name }, reason); return this.edit({ name, reason });
} }
/** /**

View File

@@ -299,11 +299,10 @@ class GuildMember extends Base {
/** /**
* Edits this member. * Edits this member.
* @param {GuildMemberEditData} data The data to edit the member with * @param {GuildMemberEditData} data The data to edit the member with
* @param {string} [reason] Reason for editing this user
* @returns {Promise<GuildMember>} * @returns {Promise<GuildMember>}
*/ */
edit(data, reason) { edit(data) {
return this.guild.members.edit(this, data, reason); return this.guild.members.edit(this, data);
} }
/** /**
@@ -313,7 +312,7 @@ class GuildMember extends Base {
* @returns {Promise<GuildMember>} * @returns {Promise<GuildMember>}
*/ */
setNickname(nick, reason) { setNickname(nick, reason) {
return this.edit({ nick }, reason); return this.edit({ nick, reason });
} }
/** /**
@@ -369,7 +368,7 @@ class GuildMember extends Base {
* .catch(console.error); * .catch(console.error);
*/ */
disableCommunicationUntil(communicationDisabledUntil, reason) { disableCommunicationUntil(communicationDisabledUntil, reason) {
return this.edit({ communicationDisabledUntil }, reason); return this.edit({ communicationDisabledUntil, reason });
} }
/** /**

View File

@@ -207,8 +207,7 @@ class Role extends Base {
/** /**
* Edits the role. * Edits the role.
* @param {RoleData} data The new data for the role * @param {EditRoleOptions} data The new data for the role
* @param {string} [reason] Reason for editing this role
* @returns {Promise<Role>} * @returns {Promise<Role>}
* @example * @example
* // Edit a role * // Edit a role
@@ -216,8 +215,8 @@ class Role extends Base {
* .then(updated => console.log(`Edited role name to ${updated.name}`)) * .then(updated => console.log(`Edited role name to ${updated.name}`))
* .catch(console.error); * .catch(console.error);
*/ */
edit(data, reason) { edit(data) {
return this.guild.roles.edit(this, data, reason); return this.guild.roles.edit(this, data);
} }
/** /**
@@ -245,7 +244,7 @@ class Role extends Base {
* .catch(console.error); * .catch(console.error);
*/ */
setName(name, reason) { setName(name, reason) {
return this.edit({ name }, reason); return this.edit({ name, reason });
} }
/** /**
@@ -260,7 +259,7 @@ class Role extends Base {
* .catch(console.error); * .catch(console.error);
*/ */
setColor(color, reason) { setColor(color, reason) {
return this.edit({ color }, reason); return this.edit({ color, reason });
} }
/** /**
@@ -275,7 +274,7 @@ class Role extends Base {
* .catch(console.error); * .catch(console.error);
*/ */
setHoist(hoist = true, reason) { 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); * .catch(console.error);
*/ */
setPermissions(permissions, reason) { setPermissions(permissions, reason) {
return this.edit({ permissions }, reason); return this.edit({ permissions, reason });
} }
/** /**
@@ -310,7 +309,7 @@ class Role extends Base {
* .catch(console.error); * .catch(console.error);
*/ */
setMentionable(mentionable = true, reason) { setMentionable(mentionable = true, reason) {
return this.edit({ mentionable }, reason); return this.edit({ mentionable, reason });
} }
/** /**
@@ -322,7 +321,7 @@ class Role extends Base {
* @returns {Promise<Role>} * @returns {Promise<Role>}
*/ */
setIcon(icon, reason) { setIcon(icon, reason) {
return this.edit({ icon }, reason); return this.edit({ icon, reason });
} }
/** /**
@@ -337,7 +336,7 @@ class Role extends Base {
* .catch(console.error); * .catch(console.error);
*/ */
setUnicodeEmoji(unicodeEmoji, reason) { setUnicodeEmoji(unicodeEmoji, reason) {
return this.edit({ unicodeEmoji }, reason); return this.edit({ unicodeEmoji, reason });
} }
/** /**

View File

@@ -49,7 +49,7 @@ class StageChannel extends BaseGuildVoiceChannel {
* .catch(console.error); * .catch(console.error);
*/ */
setTopic(topic, reason) { setTopic(topic, reason) {
return this.edit({ topic }, reason); return this.edit({ topic, reason });
} }
/** /**

View File

@@ -200,12 +200,12 @@ class Sticker extends Base {
* @property {string} [name] The name of the sticker * @property {string} [name] The name of the sticker
* @property {?string} [description] The description 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} [tags] The Discord name of a unicode emoji representing the sticker's expression
* @property {string} [reason] Reason for editing this sticker
*/ */
/** /**
* Edits the sticker. * Edits the sticker.
* @param {GuildStickerEditData} [data] The new data for the sticker * @param {GuildStickerEditData} data The new data for the sticker
* @param {string} [reason] Reason for editing this sticker
* @returns {Promise<Sticker>} * @returns {Promise<Sticker>}
* @example * @example
* // Update the name of a sticker * // 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}`)) * .then(s => console.log(`Updated the name of the sticker to ${s.name}`))
* .catch(console.error); * .catch(console.error);
*/ */
edit(data, reason) { edit(data) {
return this.guild.stickers.edit(this, data, reason); return this.guild.stickers.edit(this, data);
} }
/** /**

View File

@@ -26,7 +26,7 @@ class TextChannel extends BaseGuildTextChannel {
* @returns {Promise<TextChannel>} * @returns {Promise<TextChannel>}
*/ */
setRateLimitPerUser(rateLimitPerUser, reason) { setRateLimitPerUser(rateLimitPerUser, reason) {
return this.edit({ rateLimitPerUser }, reason); return this.edit({ rateLimitPerUser, reason });
} }
} }

View File

@@ -297,13 +297,13 @@ class ThreadChannel extends Channel {
* @property {number} [rateLimitPerUser] The rate limit per user (slowmode) for the thread in seconds * @property {number} [rateLimitPerUser] The rate limit per user (slowmode) for the thread in seconds
* @property {boolean} [locked] Whether the thread is locked * @property {boolean} [locked] Whether the thread is locked
* @property {boolean} [invitable] Whether non-moderators can add other non-moderators to a thread * @property {boolean} [invitable] Whether non-moderators can add other non-moderators to a thread
* @property {string} [reason] Reason for editing the thread
* <info>Can only be edited on {@link ChannelType.GuildPrivateThread}</info> * <info>Can only be edited on {@link ChannelType.GuildPrivateThread}</info>
*/ */
/** /**
* Edits this thread. * Edits this thread.
* @param {ThreadEditData} data The new data for this thread * @param {ThreadEditData} data The new data for this thread
* @param {string} [reason] Reason for editing this thread
* @returns {Promise<ThreadChannel>} * @returns {Promise<ThreadChannel>}
* @example * @example
* // Edit a thread * // Edit a thread
@@ -311,7 +311,7 @@ class ThreadChannel extends Channel {
* .then(editedThread => console.log(editedThread)) * .then(editedThread => console.log(editedThread))
* .catch(console.error); * .catch(console.error);
*/ */
async edit(data, reason) { async edit(data) {
const newData = await this.client.rest.patch(Routes.channel(this.id), { const newData = await this.client.rest.patch(Routes.channel(this.id), {
body: { body: {
name: (data.name ?? this.name).trim(), name: (data.name ?? this.name).trim(),
@@ -321,7 +321,7 @@ class ThreadChannel extends Channel {
locked: data.locked, locked: data.locked,
invitable: this.type === ChannelType.GuildPrivateThread ? data.invitable : undefined, invitable: this.type === ChannelType.GuildPrivateThread ? data.invitable : undefined,
}, },
reason, reason: data.reason,
}); });
return this.client.actions.ChannelUpdate.handle(newData).updated; return this.client.actions.ChannelUpdate.handle(newData).updated;
@@ -339,7 +339,7 @@ class ThreadChannel extends Channel {
* .catch(console.error); * .catch(console.error);
*/ */
setArchived(archived = true, reason) { 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); * .catch(console.error);
*/ */
setAutoArchiveDuration(autoArchiveDuration, reason) { 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) { if (this.type !== ChannelType.GuildPrivateThread) {
return Promise.reject(new RangeError('THREAD_INVITABLE_TYPE', this.type)); 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); * .catch(console.error);
*/ */
setLocked(locked = true, reason) { 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); * .catch(console.error);
*/ */
setName(name, reason) { setName(name, reason) {
return this.edit({ name }, reason); return this.edit({ name, reason });
} }
/** /**
@@ -412,7 +412,7 @@ class ThreadChannel extends Channel {
* @returns {Promise<ThreadChannel>} * @returns {Promise<ThreadChannel>}
*/ */
setRateLimitPerUser(rateLimitPerUser, reason) { setRateLimitPerUser(rateLimitPerUser, reason) {
return this.edit({ rateLimitPerUser }, reason); return this.edit({ rateLimitPerUser, reason });
} }
/** /**

View File

@@ -97,7 +97,7 @@ class VoiceChannel extends BaseGuildVoiceChannel {
* .catch(console.error); * .catch(console.error);
*/ */
setBitrate(bitrate, reason) { setBitrate(bitrate, reason) {
return this.edit({ bitrate }, reason); return this.edit({ bitrate, reason });
} }
/** /**
@@ -112,7 +112,7 @@ class VoiceChannel extends BaseGuildVoiceChannel {
* .catch(console.error); * .catch(console.error);
*/ */
setUserLimit(userLimit, reason) { setUserLimit(userLimit, reason) {
return this.edit({ userLimit }, reason); return this.edit({ userLimit, reason });
} }
/** /**
@@ -122,7 +122,7 @@ class VoiceChannel extends BaseGuildVoiceChannel {
* @returns {Promise<VoiceChannel>} * @returns {Promise<VoiceChannel>}
*/ */
setVideoQualityMode(videoQualityMode, reason) { 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 // These are here only for documentation purposes - they are implemented by TextBasedChannel

View File

@@ -172,7 +172,7 @@ class VoiceState extends Base {
* @returns {Promise<GuildMember>} * @returns {Promise<GuildMember>}
*/ */
setMute(mute = true, reason) { 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<GuildMember>} * @returns {Promise<GuildMember>}
*/ */
setDeaf(deaf = true, reason) { 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<GuildMember>} * @returns {Promise<GuildMember>}
*/ */
setChannel(channel, reason) { setChannel(channel, reason) {
return this.guild.members.edit(this.id, { channel }, reason); return this.guild.members.edit(this.id, { channel, reason });
} }
/** /**

View File

@@ -249,15 +249,15 @@ class Webhook {
* @property {string} [name=this.name] The new name for the webhook * @property {string} [name=this.name] The new name for the webhook
* @property {?(BufferResolvable)} [avatar] The new avatar for the webhook * @property {?(BufferResolvable)} [avatar] The new avatar for the webhook
* @property {GuildTextChannelResolvable} [channel] The new channel for the webhook * @property {GuildTextChannelResolvable} [channel] The new channel for the webhook
* @property {string} [reason] Reason for editing the webhook
*/ */
/** /**
* Edits this webhook. * Edits this webhook.
* @param {WebhookEditData} options Options for editing the webhook * @param {WebhookEditData} options Options for editing the webhook
* @param {string} [reason] Reason for editing the webhook
* @returns {Promise<Webhook>} * @returns {Promise<Webhook>}
*/ */
async edit({ name = this.name, avatar, channel }, reason) { async edit({ name = this.name, avatar, channel, reason }) {
if (avatar && !(typeof avatar === 'string' && avatar.startsWith('data:'))) { if (avatar && !(typeof avatar === 'string' && avatar.startsWith('data:'))) {
avatar = await DataResolver.resolveImage(avatar); avatar = await DataResolver.resolveImage(avatar);
} }

View File

@@ -345,13 +345,13 @@ class TextBasedChannel {
/** /**
* Options used to create a {@link Webhook} in a {@link TextChannel} or a {@link NewsChannel}. * Options used to create a {@link Webhook} in a {@link TextChannel} or a {@link NewsChannel}.
* @typedef {Object} ChannelWebhookCreateOptions * @typedef {Object} ChannelWebhookCreateOptions
* @property {string} name The name of the webhook
* @property {?(BufferResolvable|Base64Resolvable)} [avatar] Avatar for the webhook * @property {?(BufferResolvable|Base64Resolvable)} [avatar] Avatar for the webhook
* @property {string} [reason] Reason for creating the webhook * @property {string} [reason] Reason for creating the webhook
*/ */
/** /**
* Creates a webhook for the channel. * Creates a webhook for the channel.
* @param {string} name The name of the webhook
* @param {ChannelWebhookCreateOptions} [options] Options for creating the webhook * @param {ChannelWebhookCreateOptions} [options] Options for creating the webhook
* @returns {Promise<Webhook>} Returns the created Webhook * @returns {Promise<Webhook>} Returns the created Webhook
* @example * @example
@@ -363,8 +363,8 @@ class TextBasedChannel {
* .then(console.log) * .then(console.log)
* .catch(console.error) * .catch(console.error)
*/ */
createWebhook(name, options = {}) { createWebhook(options) {
return this.guild.channels.createWebhook(this.id, name, options); return this.guild.channels.createWebhook({ channel: this.id, ...options });
} }
/** /**
@@ -374,7 +374,7 @@ class TextBasedChannel {
* @returns {Promise<this>} * @returns {Promise<this>}
*/ */
setRateLimitPerUser(rateLimitPerUser, reason) { setRateLimitPerUser(rateLimitPerUser, reason) {
return this.edit({ rateLimitPerUser }, reason); return this.edit({ rateLimitPerUser, reason });
} }
/** /**
@@ -384,7 +384,7 @@ class TextBasedChannel {
* @returns {Promise<this>} * @returns {Promise<this>}
*/ */
setNSFW(nsfw = true, reason) { setNSFW(nsfw = true, reason) {
return this.edit({ nsfw }, reason); return this.edit({ nsfw, reason });
} }
static applyToClass(structure, full = false, ignore = []) { static applyToClass(structure, full = false, ignore = []) {

View File

@@ -1123,7 +1123,7 @@ export class Guild extends AnonymousGuild {
public createTemplate(name: string, description?: string): Promise<GuildTemplate>; public createTemplate(name: string, description?: string): Promise<GuildTemplate>;
public delete(): Promise<Guild>; public delete(): Promise<Guild>;
public discoverySplashURL(options?: ImageURLOptions): string | null; public discoverySplashURL(options?: ImageURLOptions): string | null;
public edit(data: GuildEditData, reason?: string): Promise<Guild>; public edit(data: GuildEditData): Promise<Guild>;
public editWelcomeScreen(data: WelcomeScreenEditData): Promise<WelcomeScreen>; public editWelcomeScreen(data: WelcomeScreenEditData): Promise<WelcomeScreen>;
public equals(guild: Guild): boolean; public equals(guild: Guild): boolean;
public fetchAuditLogs<T extends GuildAuditLogsResolvable = null>( public fetchAuditLogs<T extends GuildAuditLogsResolvable = null>(
@@ -1240,7 +1240,7 @@ export abstract class GuildChannel extends Channel {
public get viewable(): boolean; public get viewable(): boolean;
public clone(options?: GuildChannelCloneOptions): Promise<this>; public clone(options?: GuildChannelCloneOptions): Promise<this>;
public delete(reason?: string): Promise<this>; public delete(reason?: string): Promise<this>;
public edit(data: ChannelData, reason?: string): Promise<this>; public edit(data: ChannelEditData): Promise<this>;
public equals(channel: GuildChannel): boolean; public equals(channel: GuildChannel): boolean;
public lockPermissions(): Promise<this>; public lockPermissions(): Promise<this>;
public permissionsFor(memberOrRole: GuildMember | Role, checkAdmin?: boolean): Readonly<PermissionsBitField>; public permissionsFor(memberOrRole: GuildMember | Role, checkAdmin?: boolean): Readonly<PermissionsBitField>;
@@ -1265,7 +1265,7 @@ export class GuildEmoji extends BaseGuildEmoji {
public get roles(): GuildEmojiRoleManager; public get roles(): GuildEmojiRoleManager;
public get url(): string; public get url(): string;
public delete(reason?: string): Promise<GuildEmoji>; public delete(reason?: string): Promise<GuildEmoji>;
public edit(data: GuildEmojiEditData, reason?: string): Promise<GuildEmoji>; public edit(data: GuildEmojiEditData): Promise<GuildEmoji>;
public equals(other: GuildEmoji | unknown): boolean; public equals(other: GuildEmoji | unknown): boolean;
public fetchAuthor(): Promise<User>; public fetchAuthor(): Promise<User>;
public setName(name: string, reason?: string): Promise<GuildEmoji>; public setName(name: string, reason?: string): Promise<GuildEmoji>;
@@ -1305,7 +1305,7 @@ export class GuildMember extends PartialTextBasedChannel(Base) {
public createDM(force?: boolean): Promise<DMChannel>; public createDM(force?: boolean): Promise<DMChannel>;
public deleteDM(): Promise<DMChannel>; public deleteDM(): Promise<DMChannel>;
public displayAvatarURL(options?: ImageURLOptions): string; public displayAvatarURL(options?: ImageURLOptions): string;
public edit(data: GuildMemberEditData, reason?: string): Promise<GuildMember>; public edit(data: GuildMemberEditData): Promise<GuildMember>;
public isCommunicationDisabled(): this is GuildMember & { public isCommunicationDisabled(): this is GuildMember & {
communicationDisabledUntilTimestamp: number; communicationDisabledUntilTimestamp: number;
readonly communicationDisabledUntil: Date; readonly communicationDisabledUntil: Date;
@@ -2123,7 +2123,7 @@ export class Role extends Base {
public icon: string | null; public icon: string | null;
public unicodeEmoji: string | null; public unicodeEmoji: string | null;
public delete(reason?: string): Promise<Role>; public delete(reason?: string): Promise<Role>;
public edit(data: RoleData, reason?: string): Promise<Role>; public edit(data: EditRoleOptions): Promise<Role>;
public equals(role: Role): boolean; public equals(role: Role): boolean;
public iconURL(options?: ImageURLOptions): string | null; public iconURL(options?: ImageURLOptions): string | null;
public permissionsIn( public permissionsIn(
@@ -2337,7 +2337,7 @@ export class Sticker extends Base {
public fetch(): Promise<Sticker>; public fetch(): Promise<Sticker>;
public fetchPack(): Promise<StickerPack | null>; public fetchPack(): Promise<StickerPack | null>;
public fetchUser(): Promise<User | null>; public fetchUser(): Promise<User | null>;
public edit(data?: GuildStickerEditData, reason?: string): Promise<Sticker>; public edit(data?: GuildStickerEditData): Promise<Sticker>;
public delete(reason?: string): Promise<Sticker>; public delete(reason?: string): Promise<Sticker>;
public equals(other: Sticker | unknown): boolean; public equals(other: Sticker | unknown): boolean;
} }
@@ -2502,7 +2502,7 @@ export class ThreadChannel extends TextBasedChannelMixin(Channel, ['fetchWebhook
public type: ThreadChannelType; public type: ThreadChannelType;
public get unarchivable(): boolean; public get unarchivable(): boolean;
public delete(reason?: string): Promise<this>; public delete(reason?: string): Promise<this>;
public edit(data: ThreadEditData, reason?: string): Promise<AnyThreadChannel>; public edit(data: ThreadEditData): Promise<AnyThreadChannel>;
public join(): Promise<AnyThreadChannel>; public join(): Promise<AnyThreadChannel>;
public leave(): Promise<AnyThreadChannel>; public leave(): Promise<AnyThreadChannel>;
public permissionsFor(memberOrRole: GuildMember | Role, checkAdmin?: boolean): Readonly<PermissionsBitField>; public permissionsFor(memberOrRole: GuildMember | Role, checkAdmin?: boolean): Readonly<PermissionsBitField>;
@@ -3107,10 +3107,9 @@ export class CategoryChannelChildManager extends DataManager<
public channel: CategoryChannel; public channel: CategoryChannel;
public get guild(): Guild; public get guild(): Guild;
public create<T extends CategoryChannelType>( public create<T extends CategoryChannelType>(
name: string,
options: CategoryCreateChannelOptions & { type: T }, options: CategoryCreateChannelOptions & { type: T },
): Promise<MappedChannelCategoryTypes[T]>; ): Promise<MappedChannelCategoryTypes[T]>;
public create(name: string, options?: CategoryCreateChannelOptions): Promise<TextChannel>; public create(options: CategoryCreateChannelOptions): Promise<TextChannel>;
} }
export class ChannelManager extends CachedManager<Snowflake, AnyChannel, ChannelResolvable> { export class ChannelManager extends CachedManager<Snowflake, AnyChannel, ChannelResolvable> {
@@ -3150,16 +3149,11 @@ export class GuildChannelManager extends CachedManager<Snowflake, GuildBasedChan
public guild: Guild; public guild: Guild;
public create<T extends GuildChannelTypes>( public create<T extends GuildChannelTypes>(
name: string,
options: GuildChannelCreateOptions & { type: T }, options: GuildChannelCreateOptions & { type: T },
): Promise<MappedGuildChannelTypes[T]>; ): Promise<MappedGuildChannelTypes[T]>;
public create(name: string, options?: GuildChannelCreateOptions): Promise<TextChannel>; public create(options: GuildChannelCreateOptions): Promise<TextChannel>;
public createWebhook( public createWebhook(options: WebhookCreateOptions): Promise<Webhook>;
channel: GuildChannelResolvable, public edit(channel: GuildChannelResolvable, data: ChannelEditData): Promise<GuildChannel>;
name: string,
options?: ChannelWebhookCreateOptions,
): Promise<Webhook>;
public edit(channel: GuildChannelResolvable, data: ChannelData, reason?: string): Promise<GuildChannel>;
public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<NonThreadGuildBasedChannel | null>; public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<NonThreadGuildBasedChannel | null>;
public fetch(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, NonThreadGuildBasedChannel>>; public fetch(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, NonThreadGuildBasedChannel>>;
public fetchWebhooks(channel: GuildChannelResolvable): Promise<Collection<Snowflake, Webhook>>; public fetchWebhooks(channel: GuildChannelResolvable): Promise<Collection<Snowflake, Webhook>>;
@@ -3176,16 +3170,12 @@ export class GuildChannelManager extends CachedManager<Snowflake, GuildBasedChan
export class GuildEmojiManager extends BaseGuildEmojiManager { export class GuildEmojiManager extends BaseGuildEmojiManager {
private constructor(guild: Guild, iterable?: Iterable<RawGuildEmojiData>); private constructor(guild: Guild, iterable?: Iterable<RawGuildEmojiData>);
public guild: Guild; public guild: Guild;
public create( public create(options: GuildEmojiCreateOptions): Promise<GuildEmoji>;
attachment: BufferResolvable | Base64Resolvable,
name: string,
options?: GuildEmojiCreateOptions,
): Promise<GuildEmoji>;
public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<GuildEmoji>; public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<GuildEmoji>;
public fetch(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, GuildEmoji>>; public fetch(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, GuildEmoji>>;
public fetchAuthor(emoji: EmojiResolvable): Promise<User>; public fetchAuthor(emoji: EmojiResolvable): Promise<User>;
public delete(emoji: EmojiResolvable, reason?: string): Promise<void>; public delete(emoji: EmojiResolvable, reason?: string): Promise<void>;
public edit(emoji: EmojiResolvable, data: GuildEmojiEditData, reason?: string): Promise<GuildEmoji>; public edit(emoji: EmojiResolvable, data: GuildEmojiEditData): Promise<GuildEmoji>;
} }
export class GuildEmojiRoleManager extends DataManager<Snowflake, Role, RoleResolvable> { export class GuildEmojiRoleManager extends DataManager<Snowflake, Role, RoleResolvable> {
@@ -3203,7 +3193,7 @@ export class GuildEmojiRoleManager extends DataManager<Snowflake, Role, RoleReso
export class GuildManager extends CachedManager<Snowflake, Guild, GuildResolvable> { export class GuildManager extends CachedManager<Snowflake, Guild, GuildResolvable> {
private constructor(client: Client, iterable?: Iterable<RawGuildData>); private constructor(client: Client, iterable?: Iterable<RawGuildData>);
public create(name: string, options?: GuildCreateOptions): Promise<Guild>; public create(options: GuildCreateOptions): Promise<Guild>;
public fetch(options: Snowflake | FetchGuildOptions): Promise<Guild>; public fetch(options: Snowflake | FetchGuildOptions): Promise<Guild>;
public fetch(options?: FetchGuildsOptions): Promise<Collection<Snowflake, OAuth2Guild>>; public fetch(options?: FetchGuildsOptions): Promise<Collection<Snowflake, OAuth2Guild>>;
} }
@@ -3218,7 +3208,7 @@ export class GuildMemberManager extends CachedManager<Snowflake, GuildMember, Gu
): Promise<GuildMember | null>; ): Promise<GuildMember | null>;
public add(user: UserResolvable, options: AddGuildMemberOptions): Promise<GuildMember>; public add(user: UserResolvable, options: AddGuildMemberOptions): Promise<GuildMember>;
public ban(user: UserResolvable, options?: BanOptions): Promise<GuildMember | User | Snowflake>; public ban(user: UserResolvable, options?: BanOptions): Promise<GuildMember | User | Snowflake>;
public edit(user: UserResolvable, data: GuildMemberEditData, reason?: string): Promise<void>; public edit(user: UserResolvable, data: GuildMemberEditData): Promise<void>;
public fetch( public fetch(
options: UserResolvable | FetchMemberOptions | (FetchMembersOptions & { user: UserResolvable }), options: UserResolvable | FetchMemberOptions | (FetchMembersOptions & { user: UserResolvable }),
): Promise<GuildMember>; ): Promise<GuildMember>;
@@ -3275,13 +3265,8 @@ export class GuildScheduledEventManager extends CachedManager<
export class GuildStickerManager extends CachedManager<Snowflake, Sticker, StickerResolvable> { export class GuildStickerManager extends CachedManager<Snowflake, Sticker, StickerResolvable> {
private constructor(guild: Guild, iterable?: Iterable<RawStickerData>); private constructor(guild: Guild, iterable?: Iterable<RawStickerData>);
public guild: Guild; public guild: Guild;
public create( public create(options: GuildStickerCreateOptions): Promise<Sticker>;
file: BufferResolvable | Stream | AttachmentPayload | JSONEncodable<AttachmentBuilder>, public edit(sticker: StickerResolvable, data?: GuildStickerEditData): Promise<Sticker>;
name: string,
tags: string,
options?: GuildStickerCreateOptions,
): Promise<Sticker>;
public edit(sticker: StickerResolvable, data?: GuildStickerEditData, reason?: string): Promise<Sticker>;
public delete(sticker: StickerResolvable, reason?: string): Promise<void>; public delete(sticker: StickerResolvable, reason?: string): Promise<void>;
public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<Sticker>; public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<Sticker>;
public fetch(id?: Snowflake, options?: BaseFetchOptions): Promise<Collection<Snowflake, Sticker>>; public fetch(id?: Snowflake, options?: BaseFetchOptions): Promise<Collection<Snowflake, Sticker>>;
@@ -3380,7 +3365,7 @@ export class RoleManager extends CachedManager<Snowflake, Role, RoleResolvable>
public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<Role | null>; public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<Role | null>;
public fetch(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, Role>>; public fetch(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, Role>>;
public create(options?: CreateRoleOptions): Promise<Role>; public create(options?: CreateRoleOptions): Promise<Role>;
public edit(role: RoleResolvable, options: RoleData, reason?: string): Promise<Role>; public edit(role: RoleResolvable, options: EditRoleOptions): Promise<Role>;
public delete(role: RoleResolvable, reason?: string): Promise<void>; public delete(role: RoleResolvable, reason?: string): Promise<void>;
public setPosition(role: RoleResolvable, position: number, options?: SetRolePositionOptions): Promise<Role>; public setPosition(role: RoleResolvable, position: number, options?: SetRolePositionOptions): Promise<Role>;
public setPositions(rolePositions: readonly RolePosition[]): Promise<Guild>; public setPositions(rolePositions: readonly RolePosition[]): Promise<Guild>;
@@ -3469,7 +3454,7 @@ export interface TextBasedChannelFields extends PartialTextBasedChannelFields {
options?: MessageChannelCollectorOptionsParams<T, true>, options?: MessageChannelCollectorOptionsParams<T, true>,
): InteractionCollector<MappedInteractionTypes[T]>; ): InteractionCollector<MappedInteractionTypes[T]>;
createMessageCollector(options?: MessageCollectorOptions): MessageCollector; createMessageCollector(options?: MessageCollectorOptions): MessageCollector;
createWebhook(name: string, options?: ChannelWebhookCreateOptions): Promise<Webhook>; createWebhook(options: ChannelWebhookCreateOptions): Promise<Webhook>;
fetchWebhooks(): Promise<Collection<Snowflake, Webhook>>; fetchWebhooks(): Promise<Collection<Snowflake, Webhook>>;
sendTyping(): Promise<void>; sendTyping(): Promise<void>;
setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise<this>; setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise<this>;
@@ -3495,7 +3480,7 @@ export interface WebhookFields extends PartialWebhookFields {
get createdAt(): Date; get createdAt(): Date;
get createdTimestamp(): number; get createdTimestamp(): number;
delete(reason?: string): Promise<void>; delete(reason?: string): Promise<void>;
edit(options: WebhookEditData, reason?: string): Promise<Webhook>; edit(options: WebhookEditData): Promise<Webhook>;
sendSlackMessage(body: unknown): Promise<boolean>; sendSlackMessage(body: unknown): Promise<boolean>;
} }
@@ -3809,6 +3794,7 @@ export type CacheWithLimitsOptions = {
}; };
export interface CategoryCreateChannelOptions { export interface CategoryCreateChannelOptions {
name: string;
permissionOverwrites?: OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>; permissionOverwrites?: OverwriteResolvable[] | Collection<Snowflake, OverwriteResolvable>;
topic?: string; topic?: string;
type?: CategoryChannelType; type?: CategoryChannelType;
@@ -3845,6 +3831,10 @@ export interface ChannelData {
videoQualityMode?: VideoQualityMode | null; videoQualityMode?: VideoQualityMode | null;
} }
export interface ChannelEditData extends ChannelData {
reason?: string;
}
export type ChannelMention = `<#${Snowflake}>`; export type ChannelMention = `<#${Snowflake}>`;
export interface ChannelPosition { export interface ChannelPosition {
@@ -3858,10 +3848,15 @@ export type GuildTextChannelResolvable = TextChannel | NewsChannel | Snowflake;
export type ChannelResolvable = AnyChannel | Snowflake; export type ChannelResolvable = AnyChannel | Snowflake;
export interface ChannelWebhookCreateOptions { export interface ChannelWebhookCreateOptions {
name: string;
avatar?: BufferResolvable | Base64Resolvable | null; avatar?: BufferResolvable | Base64Resolvable | null;
reason?: string; reason?: string;
} }
export interface WebhookCreateOptions extends ChannelWebhookCreateOptions {
channel: GuildChannelResolvable;
}
export interface ClientEvents { export interface ClientEvents {
cacheSweep: [message: string]; cacheSweep: [message: string];
channelCreate: [channel: NonThreadGuildBasedChannel]; channelCreate: [channel: NonThreadGuildBasedChannel];
@@ -4166,6 +4161,10 @@ export interface CreateRoleOptions extends RoleData {
reason?: string; reason?: string;
} }
export interface EditRoleOptions extends RoleData {
reason?: string;
}
export interface StageInstanceCreateOptions { export interface StageInstanceCreateOptions {
topic: string; topic: string;
privacyLevel?: StageInstancePrivacyLevel; privacyLevel?: StageInstancePrivacyLevel;
@@ -4471,7 +4470,7 @@ export interface GuildChannelCreateOptions extends Omit<CategoryCreateChannelOpt
>; >;
} }
export interface GuildChannelCloneOptions extends GuildChannelCreateOptions { export interface GuildChannelCloneOptions extends Omit<GuildChannelCreateOptions, 'name'> {
name?: string; name?: string;
} }
@@ -4481,6 +4480,7 @@ export interface GuildChannelOverwriteOptions {
} }
export interface GuildCreateOptions { export interface GuildCreateOptions {
name: string;
afkChannelId?: Snowflake | number; afkChannelId?: Snowflake | number;
afkTimeout?: number; afkTimeout?: number;
channels?: PartialChannelData[]; channels?: PartialChannelData[];
@@ -4518,9 +4518,12 @@ export interface GuildEditData {
premiumProgressBarEnabled?: boolean; premiumProgressBarEnabled?: boolean;
description?: string | null; description?: string | null;
features?: GuildFeature[]; features?: GuildFeature[];
reason?: string;
} }
export interface GuildEmojiCreateOptions { export interface GuildEmojiCreateOptions {
attachment: BufferResolvable | Base64Resolvable;
name: string;
roles?: Collection<Snowflake, Role> | RoleResolvable[]; roles?: Collection<Snowflake, Role> | RoleResolvable[];
reason?: string; reason?: string;
} }
@@ -4528,9 +4531,13 @@ export interface GuildEmojiCreateOptions {
export interface GuildEmojiEditData { export interface GuildEmojiEditData {
name?: string; name?: string;
roles?: Collection<Snowflake, Role> | RoleResolvable[]; roles?: Collection<Snowflake, Role> | RoleResolvable[];
reason?: string;
} }
export interface GuildStickerCreateOptions { export interface GuildStickerCreateOptions {
file: BufferResolvable | Stream | AttachmentPayload | JSONEncodable<AttachmentBuilder>;
name: string;
tags: string;
description?: string | null; description?: string | null;
reason?: string; reason?: string;
} }
@@ -4539,6 +4546,7 @@ export interface GuildStickerEditData {
name?: string; name?: string;
description?: string | null; description?: string | null;
tags?: string; tags?: string;
reason?: string;
} }
export interface GuildMemberEditData { export interface GuildMemberEditData {
@@ -4548,6 +4556,7 @@ export interface GuildMemberEditData {
deaf?: boolean; deaf?: boolean;
channel?: GuildVoiceChannelResolvable | null; channel?: GuildVoiceChannelResolvable | null;
communicationDisabledUntil?: DateResolvable | null; communicationDisabledUntil?: DateResolvable | null;
reason?: string;
} }
export type GuildMemberResolvable = GuildMember | UserResolvable; export type GuildMemberResolvable = GuildMember | UserResolvable;
@@ -5218,6 +5227,7 @@ export interface ThreadEditData {
rateLimitPerUser?: number; rateLimitPerUser?: number;
locked?: boolean; locked?: boolean;
invitable?: boolean; invitable?: boolean;
reason?: string;
} }
export type ThreadMemberResolvable = ThreadMember | UserResolvable; export type ThreadMemberResolvable = ThreadMember | UserResolvable;
@@ -5257,6 +5267,7 @@ export interface WebhookEditData {
name?: string; name?: string;
avatar?: BufferResolvable | null; avatar?: BufferResolvable | null;
channel?: GuildTextChannelResolvable; channel?: GuildTextChannelResolvable;
reason?: string;
} }
export type WebhookEditMessageOptions = Pick< export type WebhookEditMessageOptions = Pick<

View File

@@ -1035,25 +1035,27 @@ expectType<Promise<ApplicationCommand>>(guildApplicationCommandManager.fetch('0'
declare const categoryChannelChildManager: CategoryChannelChildManager; declare const categoryChannelChildManager: CategoryChannelChildManager;
{ {
expectType<Promise<VoiceChannel>>(categoryChannelChildManager.create('name', { type: ChannelType.GuildVoice })); expectType<Promise<VoiceChannel>>(categoryChannelChildManager.create({ name: 'name', type: ChannelType.GuildVoice }));
expectType<Promise<TextChannel>>(categoryChannelChildManager.create('name', { type: ChannelType.GuildText })); expectType<Promise<TextChannel>>(categoryChannelChildManager.create({ name: 'name', type: ChannelType.GuildText }));
expectType<Promise<NewsChannel>>(categoryChannelChildManager.create('name', { type: ChannelType.GuildNews })); expectType<Promise<NewsChannel>>(categoryChannelChildManager.create({ name: 'name', type: ChannelType.GuildNews }));
expectType<Promise<StageChannel>>(categoryChannelChildManager.create('name', { type: ChannelType.GuildStageVoice })); expectType<Promise<StageChannel>>(
expectType<Promise<TextChannel>>(categoryChannelChildManager.create('name', {})); categoryChannelChildManager.create({ name: 'name', type: ChannelType.GuildStageVoice }),
expectType<Promise<TextChannel>>(categoryChannelChildManager.create('name')); );
expectType<Promise<TextChannel>>(categoryChannelChildManager.create({ name: 'name' }));
expectType<Promise<TextChannel>>(categoryChannelChildManager.create({ name: 'name' }));
} }
declare const guildChannelManager: GuildChannelManager; declare const guildChannelManager: GuildChannelManager;
{ {
type AnyChannel = TextChannel | VoiceChannel | CategoryChannel | NewsChannel | StageChannel; type AnyChannel = TextChannel | VoiceChannel | CategoryChannel | NewsChannel | StageChannel;
expectType<Promise<TextChannel>>(guildChannelManager.create('name')); expectType<Promise<TextChannel>>(guildChannelManager.create({ name: 'name' }));
expectType<Promise<TextChannel>>(guildChannelManager.create('name', {})); expectType<Promise<TextChannel>>(guildChannelManager.create({ name: 'name' }));
expectType<Promise<VoiceChannel>>(guildChannelManager.create('name', { type: ChannelType.GuildVoice })); expectType<Promise<VoiceChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildVoice }));
expectType<Promise<CategoryChannel>>(guildChannelManager.create('name', { type: ChannelType.GuildCategory })); expectType<Promise<CategoryChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildCategory }));
expectType<Promise<TextChannel>>(guildChannelManager.create('name', { type: ChannelType.GuildText })); expectType<Promise<TextChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildText }));
expectType<Promise<NewsChannel>>(guildChannelManager.create('name', { type: ChannelType.GuildNews })); expectType<Promise<NewsChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildNews }));
expectType<Promise<StageChannel>>(guildChannelManager.create('name', { type: ChannelType.GuildStageVoice })); expectType<Promise<StageChannel>>(guildChannelManager.create({ name: 'name', type: ChannelType.GuildStageVoice }));
expectType<Promise<Collection<Snowflake, AnyChannel>>>(guildChannelManager.fetch()); expectType<Promise<Collection<Snowflake, AnyChannel>>>(guildChannelManager.fetch());
expectType<Promise<Collection<Snowflake, AnyChannel>>>(guildChannelManager.fetch(undefined, {})); expectType<Promise<Collection<Snowflake, AnyChannel>>>(guildChannelManager.fetch(undefined, {}));