From dc9924fb5f24c8dac963d6b86ba279a89545e73b Mon Sep 17 00:00:00 2001 From: MrMythicalYT <91077061+MrMythicalYT@users.noreply.github.com> Date: Fri, 17 Feb 2023 16:56:18 -0500 Subject: [PATCH] feat(InteractionResponse): add new methods (#9132) * feat(InteractionResponse): add new methods * types: fix options parameter type Co-authored-by: Jaworek * Update packages/discord.js/src/structures/InteractionResponse.js Co-authored-by: Vlad Frangu * Update packages/discord.js/src/structures/InteractionResponse.js Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * docs: add description for edit --------- Co-authored-by: Jaworek Co-authored-by: Vlad Frangu Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../src/structures/InteractionResponse.js | 25 +++++++++++++++++++ packages/discord.js/typings/index.d.ts | 3 +++ 2 files changed, 28 insertions(+) diff --git a/packages/discord.js/src/structures/InteractionResponse.js b/packages/discord.js/src/structures/InteractionResponse.js index 3c1114c9ecc9..9b372e3932d6 100644 --- a/packages/discord.js/src/structures/InteractionResponse.js +++ b/packages/discord.js/src/structures/InteractionResponse.js @@ -70,6 +70,31 @@ class InteractionResponse { interactionType: InteractionType.MessageComponent, }); } + + /** + * Fetches the response as a {@link Message} object. + * @returns {Promise} + */ + fetch() { + return this.interaction.fetchReply(); + } + + /** + * Deletes the response. + * @returns {Promise} + */ + delete() { + return this.interaction.deleteReply(); + } + + /** + * Edits the response. + * @param {string|MessagePayload|WebhookMessageEditOptions} options The new options for the response. + * @returns {Promise} + */ + edit(options) { + return this.interaction.editReply(options); + } } // eslint-disable-next-line import/order diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 65a04616e246..10a272f3c610 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -580,6 +580,9 @@ export class InteractionResponse { public createMessageComponentCollector( options?: MessageCollectorOptionsParams, ): InteractionCollector[T]>; + public delete(): Promise; + public edit(options: string | MessagePayload | WebhookMessageEditOptions): Promise; + public fetch(): Promise; } export abstract class BaseGuild extends Base {