Skip to content

Commit

Permalink
feat: add launch activity function
Browse files Browse the repository at this point in the history
  • Loading branch information
Snazzah committed Sep 1, 2024
1 parent f9a9779 commit 91cf22a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
22 changes: 22 additions & 0 deletions src/structures/interfaces/messageInteraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean> {
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.
Expand Down

0 comments on commit 91cf22a

Please sign in to comment.