From 90178f976cf5da6c081c1e54d5dc3c0d078a8392 Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Sun, 8 Dec 2024 21:45:28 +0000 Subject: [PATCH 1/3] feat(interactions): add launchActivity method --- packages/core/src/api/interactions.ts | 50 +++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/packages/core/src/api/interactions.ts b/packages/core/src/api/interactions.ts index bc485a76200d..c50491129f45 100644 --- a/packages/core/src/api/interactions.ts +++ b/packages/core/src/api/interactions.ts @@ -450,4 +450,54 @@ export class InteractionsAPI { signal, }); } + + /** + * Launches activity and returns an interaction callback object + * + * @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response} + * @param interactionId - The id of the interaction + * @param interactionToken - The token of the interaction + * @param body - The callback data for launching the activity + * @param options - The options for launching the activity + */ + public async launchActivity( + interactionId: Snowflake, + interactionToken: string, + body?: RESTPostAPIInteractionCallbackQuery & { with_response: true }, + options?: Pick, + ): Promise; + + /** + * Launches activity + * + * @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response} + * @param interactionId - The id of the interaction + * @param interactionToken - The token of the interaction + * @param body - The callback data for launching the activity + * @param options - The options for launching the activity + */ + public async launchActivity( + interactionId: Snowflake, + interactionToken: string, + body?: RESTPostAPIInteractionCallbackQuery & { with_response?: false }, + options?: Pick, + ): Promise; + + public async launchActivity( + interactionId: Snowflake, + interactionToken: string, + { with_response }: RESTPostAPIInteractionCallbackQuery = {}, + { signal }: Pick = {}, + ) { + const response = await this.rest.post(Routes.interactionCallback(interactionId, interactionToken), { + query: makeURLSearchParams({ with_response }), + auth: false, + body: { + type: InteractionResponseType.LaunchActivity, + }, + signal, + }); + + return with_response ? response : undefined; + } } From 1fff273109772803ea918e9a0b9845909b135790 Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Fri, 3 Jan 2025 19:05:57 +0600 Subject: [PATCH 2/3] chore: suggestion Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> --- packages/core/src/api/interactions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/api/interactions.ts b/packages/core/src/api/interactions.ts index a8e3f5fa87bd..04f6cd53d8cf 100644 --- a/packages/core/src/api/interactions.ts +++ b/packages/core/src/api/interactions.ts @@ -431,7 +431,7 @@ export class InteractionsAPI { } /** - * Launches activity and returns an interaction callback object + * Launches an activity and returns an interaction callback object * * @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response} * @param interactionId - The id of the interaction From 71e1722222a2a93c394e0e0be07f619e0b1ddf89 Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Fri, 3 Jan 2025 19:06:13 +0600 Subject: [PATCH 3/3] chore: suggestion Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> --- packages/core/src/api/interactions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/api/interactions.ts b/packages/core/src/api/interactions.ts index 04f6cd53d8cf..b3fc0c0d4dd7 100644 --- a/packages/core/src/api/interactions.ts +++ b/packages/core/src/api/interactions.ts @@ -447,7 +447,7 @@ export class InteractionsAPI { ): Promise; /** - * Launches activity + * Launches an activity * * @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response} * @param interactionId - The id of the interaction