From 68b40dd91df70593c8271bd455fd0b3c6d19d334 Mon Sep 17 00:00:00 2001 From: monbrey Date: Sat, 15 May 2021 08:40:23 +1000 Subject: [PATCH] feat(CommandInteraction): ephemeral followup messages (#5618) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Antonio Román --- src/structures/CommandInteraction.js | 18 ++++++++++++++++++ typings/index.d.ts | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/src/structures/CommandInteraction.js b/src/structures/CommandInteraction.js index 2cdd9179785a..22851239e642 100644 --- a/src/structures/CommandInteraction.js +++ b/src/structures/CommandInteraction.js @@ -187,6 +187,24 @@ class CommandInteraction extends Interaction { * @property {Role|Object} [role] The resolved role */ + /** + * Send a follow-up message to this interaction. + * @param {string|APIMessage|MessageAdditions} content The content for the reply + * @param {InteractionReplyOptions} [options] Additional options for the reply + * @returns {Promise} + */ + async followUp(content, options) { + const apiMessage = content instanceof APIMessage ? content : APIMessage.create(this, content, options); + const { data, files } = await apiMessage.resolveData().resolveFiles(); + + const raw = await this.client.api.webhooks(this.applicationID, this.token).post({ + data, + files, + }); + + return this.channel?.messages.add(raw) ?? raw; + } + /** * Transforms an option received from the API. * @param {Object} option The received option diff --git a/typings/index.d.ts b/typings/index.d.ts index 6efebd1993f6..0e574ac27145 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -425,6 +425,10 @@ declare module 'discord.js' { ): Promise; public editReply(content: string, options?: WebhookEditMessageOptions): Promise; public fetchReply(): Promise; + public followUp( + content: string | APIMessage | InteractionReplyOptions | MessageAdditions, + ): Promise; + public followUp(content: string, options?: InteractionReplyOptions): Promise; public reply(content: string | APIMessage | InteractionReplyOptions | MessageAdditions): Promise; public reply(content: string, options?: InteractionReplyOptions): Promise; private transformOption(option: object, resolved: object): CommandInteractionOption;