Skip to content

Commit 017f15f

Browse files
authored
add Webhook.from_interaction
1 parent cf49aa3 commit 017f15f

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

discord/interactions.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,12 +398,7 @@ def response(self) -> InteractionResponse:
398398
@utils.cached_slot_property("_cs_followup")
399399
def followup(self) -> Webhook:
400400
"""Returns the followup webhook for followup interactions."""
401-
payload = {
402-
"id": self.application_id,
403-
"type": 3,
404-
"token": self.token,
405-
}
406-
return Webhook.from_state(data=payload, state=self._state, parent=self)
401+
return Webhook.from_interaction(interaction=self)
407402

408403
def is_guild_authorised(self) -> bool:
409404
""":class:`bool`: Checks if the interaction is guild authorised.

discord/webhook/async_.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,28 @@ def from_state(cls, data, state) -> Webhook:
13801380
token=state.http.token,
13811381
)
13821382

1383+
@classmethod
1384+
def from_interaction(cls, interaction) -> Webhook:
1385+
state = interaction._state
1386+
data = {
1387+
"id": interaction.application_id,
1388+
"type": 3,
1389+
"token": interaction.token,
1390+
}
1391+
http = state.http
1392+
session = http._HTTPClient__session
1393+
proxy_auth = http.proxy_auth
1394+
proxy = http.proxy
1395+
return cls(
1396+
data,
1397+
session=session,
1398+
state=state,
1399+
proxy_auth=proxy_auth,
1400+
proxy=proxy,
1401+
token=state.http.token,
1402+
parent=interaction,
1403+
)
1404+
13831405
async def fetch(self, *, prefer_auth: bool = True) -> Webhook:
13841406
"""|coro|
13851407

0 commit comments

Comments
 (0)