Skip to content

Commit 426d991

Browse files
committed
feat: Add Callback To All Responses
1 parent dbcb58c commit 426d991

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

discord/interactions.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ class Interaction:
129129
The user or member that sent the interaction. Will be `None` in PING interactions.
130130
message: Optional[:class:`Message`]
131131
The message that sent this interaction.
132-
This is updated to the message object of the response after responding by sending or editing a message.
133132
token: :class:`str`
134133
The token to continue the interaction. These are valid
135134
for 15 minutes.
@@ -846,7 +845,7 @@ async def defer(self, *, ephemeral: bool = False, invisible: bool = True) -> Non
846845
if defer_type:
847846
adapter = async_context.get()
848847
http = parent._state.http
849-
await self._locked_response(
848+
callback_response: InteractionCallbackResponse = await self._locked_response(
850849
adapter.create_interaction_response(
851850
parent.id,
852851
parent.token,
@@ -858,6 +857,7 @@ async def defer(self, *, ephemeral: bool = False, invisible: bool = True) -> Non
858857
)
859858
)
860859
self._responded = True
860+
await self._process_callback_response(callback_response)
861861

862862
async def pong(self) -> None:
863863
"""|coro|
@@ -880,7 +880,7 @@ async def pong(self) -> None:
880880
if parent.type is InteractionType.ping:
881881
adapter = async_context.get()
882882
http = parent._state.http
883-
await self._locked_response(
883+
callback_response: InteractionCallbackResponse = await self._locked_response(
884884
adapter.create_interaction_response(
885885
parent.id,
886886
parent.token,
@@ -891,6 +891,7 @@ async def pong(self) -> None:
891891
)
892892
)
893893
self._responded = True
894+
self._process_callback_response(callback_response)
894895

895896
async def _process_callback_response(
896897
self, callback_response: InteractionCallbackResponse
@@ -1075,9 +1076,8 @@ async def send_message(
10751076
view.parent = self._parent
10761077
self._parent._state.store_view(view)
10771078

1078-
await self._process_callback_response(callback_response)
1079-
10801079
self._responded = True
1080+
await self._process_callback_response(callback_response)
10811081
if delete_after is not None:
10821082
await self._parent.delete_original_response(delay=delete_after)
10831083
return self._parent
@@ -1240,9 +1240,8 @@ async def edit_message(
12401240
view.message = msg
12411241
state.store_view(view, message_id)
12421242

1243-
await self._process_callback_response(callback_response)
1244-
12451243
self._responded = True
1244+
await self._process_callback_response(callback_response)
12461245
if delete_after is not None:
12471246
await self._parent.delete_original_response(delay=delete_after)
12481247

@@ -1278,7 +1277,7 @@ async def send_autocomplete_result(
12781277

12791278
adapter = async_context.get()
12801279
http = parent._state.http
1281-
await self._locked_response(
1280+
callback_response: InteractionCallbackResponse = await self._locked_response(
12821281
adapter.create_interaction_response(
12831282
parent.id,
12841283
parent.token,
@@ -1291,6 +1290,7 @@ async def send_autocomplete_result(
12911290
)
12921291

12931292
self._responded = True
1293+
self._process_callback_response(callback_response)
12941294

12951295
async def send_modal(self, modal: Modal) -> Interaction:
12961296
"""|coro|
@@ -1317,7 +1317,7 @@ async def send_modal(self, modal: Modal) -> Interaction:
13171317
payload = modal.to_dict()
13181318
adapter = async_context.get()
13191319
http = parent._state.http
1320-
await self._locked_response(
1320+
callback_response: InteractionCallbackResponse = await self._locked_response(
13211321
adapter.create_interaction_response(
13221322
parent.id,
13231323
parent.token,
@@ -1329,6 +1329,7 @@ async def send_modal(self, modal: Modal) -> Interaction:
13291329
)
13301330
)
13311331
self._responded = True
1332+
self._process_callback_response(callback_response)
13321333
self._parent._state.store_modal(modal, self._parent.user.id)
13331334
return self._parent
13341335

@@ -1356,7 +1357,7 @@ async def premium_required(self) -> Interaction:
13561357

13571358
adapter = async_context.get()
13581359
http = parent._state.http
1359-
await self._locked_response(
1360+
callback_response: InteractionCallbackResponse = await self._locked_response(
13601361
adapter.create_interaction_response(
13611362
parent.id,
13621363
parent.token,
@@ -1367,6 +1368,7 @@ async def premium_required(self) -> Interaction:
13671368
)
13681369
)
13691370
self._responded = True
1371+
self._process_callback_response(callback_response)
13701372
return self._parent
13711373

13721374
async def _locked_response(self, coro: Coroutine[Any, Any, Any]) -> Any:

0 commit comments

Comments
 (0)