From ff55a787937bb344d8c1e73f92cf91c6ff4e40fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Susa=C3=B1a?= Date: Mon, 30 Dec 2024 04:00:54 -0400 Subject: [PATCH] feat: add AnyContext.followup (#318) * fix: return support node18 * feat: support AnyContext.followup --- src/commands/applications/chatcontext.ts | 19 ++++++++++--------- src/commands/applications/entrycontext.ts | 5 +++++ src/commands/applications/menucontext.ts | 5 +++++ src/components/componentcontext.ts | 5 +++++ src/components/modalcontext.ts | 5 +++++ 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/commands/applications/chatcontext.ts b/src/commands/applications/chatcontext.ts index 5b4ef61..69a40fc 100644 --- a/src/commands/applications/chatcontext.ts +++ b/src/commands/applications/chatcontext.ts @@ -10,7 +10,11 @@ import type { WebhookMessageStructure, } from '../../client/transformers'; import type { If, MakeRequired, UnionToTuple, When } from '../../common'; -import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest } from '../../common/types/write'; +import type { + InteractionCreateBodyRequest, + InteractionMessageUpdateBodyRequest, + MessageWebhookCreateBodyRequest, +} from '../../common/types/write'; import { type AllChannels, ChatInputCommandInteraction, type Message } from '../../structures'; import { MessageFlags } from '../../types'; import { BaseContext } from '../basecontext'; @@ -54,14 +58,6 @@ export class CommandContext< metadata: CommandMetadata> = {} as never; globalMetadata: GlobalMetadata = {}; - get proxy() { - return this.client.proxy; - } - - get t() { - return this.client.t(this.interaction?.locale ?? this.client.langs.defaultLang ?? 'en-US'); - } - get fullCommandName() { return this.resolver.fullCommandName; } @@ -136,6 +132,11 @@ export class CommandContext< return this.write(body as InteractionCreateBodyRequest, withResponse); } + followup(body: MessageWebhookCreateBodyRequest) { + if (this.interaction) return this.interaction.followup(body); + return this.messageResponse!.reply(body); + } + async fetchResponse(): Promise< If > { diff --git a/src/commands/applications/entrycontext.ts b/src/commands/applications/entrycontext.ts index ec8461b..1242593 100644 --- a/src/commands/applications/entrycontext.ts +++ b/src/commands/applications/entrycontext.ts @@ -10,6 +10,7 @@ import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, MakeRequired, + MessageWebhookCreateBodyRequest, ModalCreateBodyRequest, UnionToTuple, When, @@ -77,6 +78,10 @@ export class EntryPointContext ex return this.interaction.editOrReply(body as InteractionCreateBodyRequest, withResponse); } + followup(body: MessageWebhookCreateBodyRequest) { + return this.interaction.followup(body); + } + fetchResponse(): Promise { return this.interaction.fetchResponse(); } diff --git a/src/commands/applications/menucontext.ts b/src/commands/applications/menucontext.ts index a903dd1..7e3f28a 100644 --- a/src/commands/applications/menucontext.ts +++ b/src/commands/applications/menucontext.ts @@ -11,6 +11,7 @@ import { type InteractionCreateBodyRequest, type InteractionMessageUpdateBodyRequest, type MakeRequired, + type MessageWebhookCreateBodyRequest, type ModalCreateBodyRequest, type UnionToTuple, type When, @@ -101,6 +102,10 @@ export class MenuCommandContext< return this.interaction.editOrReply(body as InteractionCreateBodyRequest, withResponse); } + followup(body: MessageWebhookCreateBodyRequest) { + return this.interaction.followup(body); + } + fetchResponse(): Promise { return this.interaction.fetchResponse(); } diff --git a/src/components/componentcontext.ts b/src/components/componentcontext.ts index 3afe6f5..59c6119 100644 --- a/src/components/componentcontext.ts +++ b/src/components/componentcontext.ts @@ -23,6 +23,7 @@ import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, MakeRequired, + MessageWebhookCreateBodyRequest, ModalCreateBodyRequest, UnionToTuple, When, @@ -130,6 +131,10 @@ export class ComponentContext< return this.interaction.editOrReply(body as InteractionCreateBodyRequest, fetchReply); } + followup(body: MessageWebhookCreateBodyRequest) { + return this.interaction.followup(body); + } + /** * @returns A Promise that resolves to the fetched message */ diff --git a/src/components/modalcontext.ts b/src/components/modalcontext.ts index 83f6a60..0b9dac9 100644 --- a/src/components/modalcontext.ts +++ b/src/components/modalcontext.ts @@ -12,6 +12,7 @@ import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, MakeRequired, + MessageWebhookCreateBodyRequest, ModalCreateBodyRequest, UnionToTuple, When, @@ -99,6 +100,10 @@ export class ModalContext extends return this.interaction.editOrReply(body as InteractionCreateBodyRequest, fetchReply); } + followup(body: MessageWebhookCreateBodyRequest) { + return this.interaction.followup(body); + } + /** * @returns A Promise that resolves to the fetched message */