Skip to content

Commit caa7833

Browse files
imnaiyarJiralitekodiakhq[bot]
committed
feat(interactions): add launchActivity method (#10646)
* feat(interactions): add launchActivity method * chore: suggestion Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * chore: suggestion Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * fix: overload and add tests * chore: wording * chore: wording * chore: spacing --------- Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent b14d8d9 commit caa7833

File tree

1 file changed

+67
-1
lines changed

1 file changed

+67
-1
lines changed

packages/core/src/api/interactions.ts

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ export class InteractionsAPI {
528528
}
529529

530530
/**
531-
* Sends a premium required response to an interaction
531+
* Launches an activity and returns an interaction callback object
532532
*
533533
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
534534
* @param interactionId - The id of the interaction
@@ -549,4 +549,70 @@ export class InteractionsAPI {
549549
signal,
550550
});
551551
}
552+
553+
/**
554+
* Launches an activity and returns an interaction callback object
555+
*
556+
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
557+
* @param interactionId - The id of the interaction
558+
* @param interactionToken - The token of the interaction
559+
* @param body - The callback data for launching the activity
560+
* @param options - The options for launching the activity
561+
*/
562+
public async launchActivity(
563+
interactionId: Snowflake,
564+
interactionToken: string,
565+
body: RESTPostAPIInteractionCallbackQuery & { with_response: true },
566+
options?: Pick<RequestData, 'signal'>,
567+
): Promise<RESTPostAPIInteractionCallbackWithResponseResult>;
568+
569+
/**
570+
* Launches an activity
571+
*
572+
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
573+
* @param interactionId - The id of the interaction
574+
* @param interactionToken - The token of the interaction
575+
* @param body - The callback data for launching the activity
576+
* @param options - The options for launching the activity
577+
*/
578+
public async launchActivity(
579+
interactionId: Snowflake,
580+
interactionToken: string,
581+
body?: RESTPostAPIInteractionCallbackQuery & { with_response?: false },
582+
options?: Pick<RequestData, 'signal'>,
583+
): Promise<undefined>;
584+
585+
/**
586+
* Launches an activity
587+
*
588+
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
589+
* @param interactionId - The id of the interaction
590+
* @param interactionToken - The token of the interaction
591+
* @param body - The callback data for launching the activity
592+
* @param options - The options for launching the activity
593+
*/
594+
public async launchActivity(
595+
interactionId: Snowflake,
596+
interactionToken: string,
597+
body?: RESTPostAPIInteractionCallbackQuery,
598+
options?: Pick<RequestData, 'signal'>,
599+
): Promise<RESTPostAPIInteractionCallbackWithResponseResult | undefined>;
600+
601+
public async launchActivity(
602+
interactionId: Snowflake,
603+
interactionToken: string,
604+
{ with_response }: RESTPostAPIInteractionCallbackQuery = {},
605+
{ signal }: Pick<RequestData, 'signal'> = {},
606+
) {
607+
const response = await this.rest.post(Routes.interactionCallback(interactionId, interactionToken), {
608+
query: makeURLSearchParams({ with_response }),
609+
auth: false,
610+
body: {
611+
type: InteractionResponseType.LaunchActivity,
612+
},
613+
signal,
614+
});
615+
616+
return with_response ? response : undefined;
617+
}
552618
}

0 commit comments

Comments
 (0)