From 91cf22a178fcbe488efebd2f346ff02b7569ecd1 Mon Sep 17 00:00:00 2001 From: Snazzah Date: Sun, 1 Sep 2024 08:18:50 -0500 Subject: [PATCH] feat: add launch activity function --- src/constants.ts | 4 +++- .../interfaces/messageInteraction.ts | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/constants.ts b/src/constants.ts index 732a5e1e..33eceedb 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -54,7 +54,9 @@ export enum InteractionResponseType { * Respond to an interaction with prompt for a premium subscription. * @deprecated Use `ComponentButtonPremium` instead. */ - PREMIUM_REQUIRED = 10 + PREMIUM_REQUIRED = 10, + /** Launch the activity for this application */ + LAUNCH_ACTIVITY = 12 } /** Message flags for interaction responses. */ diff --git a/src/structures/interfaces/messageInteraction.ts b/src/structures/interfaces/messageInteraction.ts index 1fd7830e..ee9a5767 100644 --- a/src/structures/interfaces/messageInteraction.ts +++ b/src/structures/interfaces/messageInteraction.ts @@ -235,6 +235,28 @@ export class MessageInteractionContext< return false; } + /** + * Launches the activity this app is associated with. + * @returns Whether the message passed + */ + async launchActivity(): Promise { + if (!this.initiallyResponded && !this.deferred) { + this.initiallyResponded = true; + this.deferred = true; + clearTimeout(this._timeout); + await this._respond({ + status: 200, + body: { + type: InteractionResponseType.LAUNCH_ACTIVITY, + data: {} + } + }); + return true; + } + + return false; + } + /** * Registers a component callback from the initial message. * This unregisters automatically when the context expires.