Skip to content

Commit 9fc3e5e

Browse files
fix: Adjust reason in methods options (#10977)
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 <[email protected]>
1 parent 19e74b1 commit 9fc3e5e

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

packages/core/src/api/channel.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,13 @@ export class ChannelsAPI {
223223
public async edit(
224224
channelId: Snowflake,
225225
body: RESTPatchAPIChannelJSONBody,
226-
{ signal }: Pick<RequestData, 'signal'> = {},
226+
{ signal, reason }: Pick<RequestData, 'reason' | 'signal'> = {},
227227
) {
228-
return this.rest.patch(Routes.channel(channelId), { body, signal }) as Promise<RESTPatchAPIChannelResult>;
228+
return this.rest.patch(Routes.channel(channelId), {
229+
reason,
230+
body,
231+
signal,
232+
}) as Promise<RESTPatchAPIChannelResult>;
229233
}
230234

231235
/**
@@ -235,8 +239,8 @@ export class ChannelsAPI {
235239
* @param channelId - The id of the channel to delete
236240
* @param options - The options for deleting the channel
237241
*/
238-
public async delete(channelId: Snowflake, { signal }: Pick<RequestData, 'signal'> = {}) {
239-
return this.rest.delete(Routes.channel(channelId), { signal }) as Promise<RESTDeleteAPIChannelResult>;
242+
public async delete(channelId: Snowflake, { signal, reason }: Pick<RequestData, 'reason' | 'signal'> = {}) {
243+
return this.rest.delete(Routes.channel(channelId), { signal, reason }) as Promise<RESTDeleteAPIChannelResult>;
240244
}
241245

242246
/**
@@ -441,11 +445,12 @@ export class ChannelsAPI {
441445
channelId: Snowflake,
442446
body: RESTPostAPIChannelThreadsJSONBody,
443447
messageId?: Snowflake,
444-
{ signal }: Pick<RequestData, 'signal'> = {},
448+
{ signal, reason }: Pick<RequestData, 'reason' | 'signal'> = {},
445449
) {
446450
return this.rest.post(Routes.threads(channelId, messageId), {
447451
body,
448452
signal,
453+
reason,
449454
}) as Promise<RESTPostAPIChannelThreadsResult>;
450455
}
451456

@@ -460,7 +465,7 @@ export class ChannelsAPI {
460465
public async createForumThread(
461466
channelId: Snowflake,
462467
{ message, ...optionsBody }: StartForumThreadOptions,
463-
{ signal }: Pick<RequestData, 'signal'> = {},
468+
{ signal, reason }: Pick<RequestData, 'reason' | 'signal'> = {},
464469
) {
465470
const { files, ...messageBody } = message;
466471

@@ -469,7 +474,12 @@ export class ChannelsAPI {
469474
message: messageBody,
470475
};
471476

472-
return this.rest.post(Routes.threads(channelId), { files, body, signal }) as Promise<APIThreadChannel>;
477+
return this.rest.post(Routes.threads(channelId), {
478+
files,
479+
body,
480+
reason,
481+
signal,
482+
}) as Promise<APIThreadChannel>;
473483
}
474484

475485
/**

packages/core/src/api/guild.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ export class GuildsAPI {
198198
* @param guildId - The id of the guild to delete
199199
* @param options - The options for deleting this guild
200200
*/
201-
public async delete(guildId: Snowflake, { signal, reason }: Pick<RequestData, 'reason' | 'signal'> = {}) {
202-
await this.rest.delete(Routes.guild(guildId), { reason, signal });
201+
public async delete(guildId: Snowflake, { signal }: Pick<RequestData, 'signal'> = {}) {
202+
await this.rest.delete(Routes.guild(guildId), { signal });
203203
}
204204

205205
/**

0 commit comments

Comments
 (0)