From 35cc57ab92c797d3747dd4e5ebd491c05eae6456 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Fri, 11 Jul 2025 00:16:07 +0100 Subject: [PATCH] fix: Adjust `reason` in methods options (#10976) * fix(channel): allow reason in editing * fix(channel): allow reason in `delete()` * fix(channel): allow reason in creating threads * chore: run format * fix(guild): remove incorrect `reason` option --------- Co-authored-by: Danial Raza --- packages/core/src/api/channel.ts | 29 ++++++++++++++++++++++------- packages/core/src/api/guild.ts | 7 ++----- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/packages/core/src/api/channel.ts b/packages/core/src/api/channel.ts index e33ad92e8..9f038d0f3 100644 --- a/packages/core/src/api/channel.ts +++ b/packages/core/src/api/channel.ts @@ -284,9 +284,14 @@ export class ChannelsAPI { public async edit( channelId: Snowflake, body: RESTPatchAPIChannelJSONBody, - { auth, signal }: Pick = {}, + { auth, signal, reason }: Pick = {}, ) { - return this.rest.patch(Routes.channel(channelId), { auth, body, signal }) as Promise; + return this.rest.patch(Routes.channel(channelId), { + auth, + reason, + body, + signal, + }) as Promise; } /** @@ -296,8 +301,11 @@ export class ChannelsAPI { * @param channelId - The id of the channel to delete * @param options - The options for deleting the channel */ - public async delete(channelId: Snowflake, { auth, signal }: Pick = {}) { - return this.rest.delete(Routes.channel(channelId), { auth, signal }) as Promise; + public async delete( + channelId: Snowflake, + { auth, signal, reason }: Pick = {}, + ) { + return this.rest.delete(Routes.channel(channelId), { auth, signal, reason }) as Promise; } /** @@ -511,12 +519,13 @@ export class ChannelsAPI { channelId: Snowflake, body: RESTPostAPIChannelThreadsJSONBody, messageId?: Snowflake, - { auth, signal }: Pick = {}, + { auth, signal, reason }: Pick = {}, ) { return this.rest.post(Routes.threads(channelId, messageId), { auth, body, signal, + reason, }) as Promise; } @@ -531,7 +540,7 @@ export class ChannelsAPI { public async createForumThread( channelId: Snowflake, { message, ...optionsBody }: StartForumThreadOptions, - { auth, signal }: Pick = {}, + { auth, signal, reason }: Pick = {}, ) { const { files, ...messageBody } = message; @@ -540,7 +549,13 @@ export class ChannelsAPI { message: messageBody, }; - return this.rest.post(Routes.threads(channelId), { auth, files, body, signal }) as Promise; + return this.rest.post(Routes.threads(channelId), { + auth, + files, + body, + reason, + signal, + }) as Promise; } /** diff --git a/packages/core/src/api/guild.ts b/packages/core/src/api/guild.ts index fe01b2ccc..39e929efc 100644 --- a/packages/core/src/api/guild.ts +++ b/packages/core/src/api/guild.ts @@ -187,11 +187,8 @@ export class GuildsAPI { * @param guildId - The id of the guild to delete * @param options - The options for deleting this guild */ - public async delete( - guildId: Snowflake, - { auth, reason, signal }: Pick = {}, - ) { - await this.rest.delete(Routes.guild(guildId), { auth, reason, signal }); + public async delete(guildId: Snowflake, { auth, signal }: Pick = {}) { + await this.rest.delete(Routes.guild(guildId), { auth, signal }); } /**