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 <danialrazafb@gmail.com>
This commit is contained in:
Jiralite
2025-07-11 00:16:07 +01:00
committed by GitHub
parent 7242352884
commit 35cc57ab92
2 changed files with 24 additions and 12 deletions

View File

@@ -284,9 +284,14 @@ export class ChannelsAPI {
public async edit( public async edit(
channelId: Snowflake, channelId: Snowflake,
body: RESTPatchAPIChannelJSONBody, body: RESTPatchAPIChannelJSONBody,
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {}, { auth, signal, reason }: Pick<RequestData, 'auth' | 'reason' | 'signal'> = {},
) { ) {
return this.rest.patch(Routes.channel(channelId), { auth, body, signal }) as Promise<RESTPatchAPIChannelResult>; return this.rest.patch(Routes.channel(channelId), {
auth,
reason,
body,
signal,
}) as Promise<RESTPatchAPIChannelResult>;
} }
/** /**
@@ -296,8 +301,11 @@ export class ChannelsAPI {
* @param channelId - The id of the channel to delete * @param channelId - The id of the channel to delete
* @param options - The options for deleting the channel * @param options - The options for deleting the channel
*/ */
public async delete(channelId: Snowflake, { auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {}) { public async delete(
return this.rest.delete(Routes.channel(channelId), { auth, signal }) as Promise<RESTDeleteAPIChannelResult>; channelId: Snowflake,
{ auth, signal, reason }: Pick<RequestData, 'auth' | 'reason' | 'signal'> = {},
) {
return this.rest.delete(Routes.channel(channelId), { auth, signal, reason }) as Promise<RESTDeleteAPIChannelResult>;
} }
/** /**
@@ -511,12 +519,13 @@ export class ChannelsAPI {
channelId: Snowflake, channelId: Snowflake,
body: RESTPostAPIChannelThreadsJSONBody, body: RESTPostAPIChannelThreadsJSONBody,
messageId?: Snowflake, messageId?: Snowflake,
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {}, { auth, signal, reason }: Pick<RequestData, 'auth' | 'reason' | 'signal'> = {},
) { ) {
return this.rest.post(Routes.threads(channelId, messageId), { return this.rest.post(Routes.threads(channelId, messageId), {
auth, auth,
body, body,
signal, signal,
reason,
}) as Promise<RESTPostAPIChannelThreadsResult>; }) as Promise<RESTPostAPIChannelThreadsResult>;
} }
@@ -531,7 +540,7 @@ export class ChannelsAPI {
public async createForumThread( public async createForumThread(
channelId: Snowflake, channelId: Snowflake,
{ message, ...optionsBody }: StartForumThreadOptions, { message, ...optionsBody }: StartForumThreadOptions,
{ auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {}, { auth, signal, reason }: Pick<RequestData, 'auth' | 'reason' | 'signal'> = {},
) { ) {
const { files, ...messageBody } = message; const { files, ...messageBody } = message;
@@ -540,7 +549,13 @@ export class ChannelsAPI {
message: messageBody, message: messageBody,
}; };
return this.rest.post(Routes.threads(channelId), { auth, files, body, signal }) as Promise<APIThreadChannel>; return this.rest.post(Routes.threads(channelId), {
auth,
files,
body,
reason,
signal,
}) as Promise<APIThreadChannel>;
} }
/** /**

View File

@@ -187,11 +187,8 @@ export class GuildsAPI {
* @param guildId - The id of the guild to delete * @param guildId - The id of the guild to delete
* @param options - The options for deleting this guild * @param options - The options for deleting this guild
*/ */
public async delete( public async delete(guildId: Snowflake, { auth, signal }: Pick<RequestData, 'auth' | 'signal'> = {}) {
guildId: Snowflake, await this.rest.delete(Routes.guild(guildId), { auth, signal });
{ auth, reason, signal }: Pick<RequestData, 'auth' | 'reason' | 'signal'> = {},
) {
await this.rest.delete(Routes.guild(guildId), { auth, reason, signal });
} }
/** /**