From 59546a485184cc84fb006e6b2ef7a9e85a6fdc81 Mon Sep 17 00:00:00 2001 From: Joosemi02 <37875402+Joosemi02@users.noreply.github.com> Date: Thu, 3 Jul 2025 00:54:57 +0200 Subject: [PATCH] Add support for launch_activity interaction response --- discord/enums.py | 1 + discord/interactions.py | 46 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/discord/enums.py b/discord/enums.py index 7915bcb4b..71f755c12 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -621,6 +621,7 @@ class InteractionResponseType(Enum): autocomplete_result = 8 modal = 9 # for modals # premium_required = 10 (deprecated) + launch_activity = 12 class VideoQualityMode(Enum): diff --git a/discord/interactions.py b/discord/interactions.py index abe47efa2..82b35e392 100644 --- a/discord/interactions.py +++ b/discord/interactions.py @@ -1296,6 +1296,52 @@ class InteractionResponse(Generic[ClientT]): self._response_type = InteractionResponseType.autocomplete_result + async def launch_activity(self) -> InteractionCallbackResponse[ClientT]: + """|coro| + + Responds to this interaction by launching the activity associated with the app. + Only available for apps with activities enabled. + + .. versionadded:: 2.6 + + Raises + ------- + HTTPException + Launching the activity failed. + InteractionResponded + This interaction has already been responded to before. + + Returns + ------- + :class:`InteractionCallbackResponse` + The interaction callback data. + """ + if self._response_type: + raise InteractionResponded(self._parent) + + parent = self._parent + + adapter = async_context.get() + http = parent._state.http + + params = interaction_response_params(InteractionResponseType.launch_activity.value) + response = await adapter.create_interaction_response( + parent.id, + parent.token, + session=parent._session, + proxy=http.proxy, + proxy_auth=http.proxy_auth, + params=params, + ) + self._response_type = InteractionResponseType.launch_activity + + return InteractionCallbackResponse( + data=response, + parent=self._parent, + state=self._parent._state, + type=self._response_type, + ) + class _InteractionMessageState: __slots__ = ('_parent', '_interaction')