diff --git a/packages/discord.js/src/structures/interfaces/InteractionResponses.js b/packages/discord.js/src/structures/interfaces/InteractionResponses.js index f85fd7fe9a14..5d07325756b0 100644 --- a/packages/discord.js/src/structures/interfaces/InteractionResponses.js +++ b/packages/discord.js/src/structures/interfaces/InteractionResponses.js @@ -122,49 +122,56 @@ class InteractionResponses { } /** - * Fetches the initial reply to this interaction. + * Fetches a reply to this interaction. * @see Webhook#fetchMessage + * @param {Snowflake|'@original'} [message='@original'] The response to fetch * @returns {Promise} * @example - * // Fetch the reply to this interaction + * // Fetch the initial reply to this interaction * interaction.fetchReply() * .then(reply => console.log(`Replied with ${reply.content}`)) * .catch(console.error); */ - fetchReply() { - return this.webhook.fetchMessage('@original'); + fetchReply(message = '@original') { + return this.webhook.fetchMessage(message); } /** - * Edits the initial reply to this interaction. + * @typedef {WebhookEditMessageOptions} InteractionEditReplyOptions + * @property {MessageResolvable|'@original'} [message='@original'] The response to edit + */ + + /** + * Edits a reply to this interaction. * @see Webhook#editMessage - * @param {string|MessagePayload|WebhookEditMessageOptions} options The new options for the message + * @param {string|MessagePayload|InteractionEditReplyOptions} options The new options for the message * @returns {Promise} * @example - * // Edit the reply to this interaction + * // Edit the initial reply to this interaction * interaction.editReply('New content') * .then(console.log) * .catch(console.error); */ async editReply(options) { if (!this.deferred && !this.replied) throw new DiscordjsError(ErrorCodes.InteractionNotReplied); - const message = await this.webhook.editMessage('@original', options); + const msg = await this.webhook.editMessage(options.message ?? '@original', options); this.replied = true; - return message; + return msg; } /** - * Deletes the initial reply to this interaction. + * Deletes a reply to this interaction. * @see Webhook#deleteMessage + * @param {MessageResolvable|'@original'} [message='@original'] The response to delete * @returns {Promise} * @example - * // Delete the reply to this interaction + * // Delete the initial reply to this interaction * interaction.deleteReply() * .then(console.log) * .catch(console.error); */ - async deleteReply() { - await this.webhook.deleteMessage('@original'); + async deleteReply(message = '@original') { + await this.webhook.deleteMessage(message); } /** diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 4f19cf405fed..5edb087bf6b7 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -439,11 +439,11 @@ export abstract class CommandInteraction e options: InteractionDeferReplyOptions & { fetchReply: true }, ): Promise>>; public deferReply(options?: InteractionDeferReplyOptions): Promise>>; - public deleteReply(): Promise; + public deleteReply(message?: MessageResolvable | '@original'): Promise; public editReply( - options: string | MessagePayload | WebhookEditMessageOptions, + options: string | MessagePayload | InteractionEditReplyOptions, ): Promise>>; - public fetchReply(): Promise>>; + public fetchReply(message?: Snowflake | '@original'): Promise>>; public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise>>; public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise>>; public reply( @@ -1830,11 +1830,11 @@ export class MessageComponentInteraction e options: InteractionDeferUpdateOptions & { fetchReply: true }, ): Promise>>; public deferUpdate(options?: InteractionDeferUpdateOptions): Promise>>; - public deleteReply(): Promise; + public deleteReply(message?: MessageResolvable | '@original'): Promise; public editReply( - options: string | MessagePayload | WebhookEditMessageOptions, + options: string | MessagePayload | InteractionEditReplyOptions, ): Promise>>; - public fetchReply(): Promise>>; + public fetchReply(message?: Snowflake | '@original'): Promise>>; public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise>>; public reply(options: InteractionReplyOptions & { fetchReply: true }): Promise>>; public reply( @@ -2020,15 +2020,15 @@ export class ModalSubmitInteraction extend public reply( options: string | MessagePayload | InteractionReplyOptions, ): Promise>>; - public deleteReply(): Promise; + public deleteReply(message?: MessageResolvable | '@original'): Promise; public editReply( - options: string | MessagePayload | WebhookEditMessageOptions, + options: string | MessagePayload | InteractionEditReplyOptions, ): Promise>>; public deferReply( options: InteractionDeferReplyOptions & { fetchReply: true }, ): Promise>>; public deferReply(options?: InteractionDeferReplyOptions): Promise>>; - public fetchReply(): Promise>>; + public fetchReply(message?: Snowflake | '@original'): Promise>>; public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise>>; public deferUpdate( options: InteractionDeferUpdateOptions & { fetchReply: true }, @@ -5758,6 +5758,10 @@ export interface WebhookEditMessageOptions extends Omit