Skip to content

Commit 1d16236

Browse files
authored
Proxy webhooks and interactions (#1655)
1 parent 9607b50 commit 1d16236

File tree

3 files changed

+171
-29
lines changed

3 files changed

+171
-29
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010
- New Guild Feature `INVITES_DISABLED` ([#1613](https://github.com/Pycord-Development/pycord/pull/1613))
1111
- `suppress` kwarg to `Messageable.send()` ([#1587](https://github.com/Pycord-Development/pycord/pull/1587))
12+
- `proxy` and `proxy_auth` params to many Webhook related methods.
13+
([#1655](https://github.com/Pycord-Development/pycord/pull/1655))
1214

1315
### Fixed
1416
- Various fixes to ext.bridge groups ([#1633](https://github.com/Pycord-Development/pycord/pull/1633) &
1517
[#1631](https://github.com/Pycord-Development/pycord/pull/1631))
1618
- Fix `VOICE_SERVER_UPDATE` error ([#1624](https://github.com/Pycord-Development/pycord/pull/1624))
1719
- Removed unnecessary instance check in autocomplete. ([#1643](https://github.com/Pycord-Development/pycord/pull/1643))
20+
- Interaction responses are now passed the respective `proxy` and `proxy_auth` params as defined in `Client`.
21+
([#1655](https://github.com/Pycord-Development/pycord/pull/1655))
1822

1923
## [2.1.3] - 2022-09-06
2024
### Fixed

discord/interactions.py

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,13 @@ async def original_message(self) -> InteractionMessage:
296296
raise ClientException("Channel for message could not be resolved")
297297

298298
adapter = async_context.get()
299+
http = self._state.http
299300
data = await adapter.get_original_interaction_response(
300301
application_id=self.application_id,
301302
token=self.token,
302303
session=self._session,
304+
proxy=http.proxy,
305+
proxy_auth=http.proxy_auth,
303306
)
304307
state = _InteractionMessageState(self, self._state)
305308
message = InteractionMessage(state=state, channel=channel, data=data) # type: ignore
@@ -387,10 +390,13 @@ async def edit_original_message(
387390
previous_allowed_mentions=previous_mentions,
388391
)
389392
adapter = async_context.get()
393+
http = self._state.http
390394
data = await adapter.edit_original_interaction_response(
391395
self.application_id,
392396
self.token,
393397
session=self._session,
398+
proxy=http.proxy,
399+
proxy_auth=http.proxy_auth,
394400
payload=params.payload,
395401
multipart=params.multipart,
396402
files=params.files,
@@ -429,10 +435,13 @@ async def delete_original_message(self, *, delay: Optional[float] = None) -> Non
429435
Deleted a message that is not yours.
430436
"""
431437
adapter = async_context.get()
438+
http = self._state.http
432439
func = adapter.delete_original_interaction_response(
433440
self.application_id,
434441
self.token,
435442
session=self._session,
443+
proxy=http.proxy,
444+
proxy_auth=http.proxy_auth,
436445
)
437446

438447
if delay is not None:
@@ -566,13 +575,16 @@ async def defer(self, *, ephemeral: bool = False, invisible: bool = True) -> Non
566575

567576
if defer_type:
568577
adapter = async_context.get()
578+
http = parent._state.http
569579
await self._locked_response(
570580
adapter.create_interaction_response(
571581
parent.id,
572582
parent.token,
573583
session=parent._session,
574584
type=defer_type,
575585
data=data,
586+
proxy=http.proxy,
587+
proxy_auth=http.proxy_auth,
576588
)
577589
)
578590
self._responded = True
@@ -597,11 +609,14 @@ async def pong(self) -> None:
597609
parent = self._parent
598610
if parent.type is InteractionType.ping:
599611
adapter = async_context.get()
612+
http = parent._state.http
600613
await self._locked_response(
601614
adapter.create_interaction_response(
602615
parent.id,
603616
parent.token,
604617
session=parent._session,
618+
proxy=http.proxy,
619+
proxy_auth=http.proxy_auth,
605620
type=InteractionResponseType.pong.value,
606621
)
607622
)
@@ -723,13 +738,16 @@ async def send_message(
723738

724739
parent = self._parent
725740
adapter = async_context.get()
741+
http = parent._state.http
726742
try:
727743
await self._locked_response(
728744
adapter.create_interaction_response(
729745
parent.id,
730746
parent.token,
731747
session=parent._session,
732748
type=InteractionResponseType.channel_message.value,
749+
proxy=http.proxy,
750+
proxy_auth=http.proxy_auth,
733751
data=payload,
734752
files=files,
735753
)
@@ -852,13 +870,16 @@ async def edit_message(
852870
payload["attachments"] = [a.to_dict() for a in msg.attachments]
853871

854872
adapter = async_context.get()
873+
http = parent._state.http
855874
try:
856875
await self._locked_response(
857876
adapter.create_interaction_response(
858877
parent.id,
859878
parent.token,
860879
session=parent._session,
861880
type=InteractionResponseType.message_update.value,
881+
proxy=http.proxy,
882+
proxy_auth=http.proxy_auth,
862883
data=payload,
863884
files=files,
864885
)
@@ -906,11 +927,14 @@ async def send_autocomplete_result(
906927
payload = {"choices": [c.to_dict() for c in choices]}
907928

908929
adapter = async_context.get()
930+
http = parent._state.http
909931
await self._locked_response(
910932
adapter.create_interaction_response(
911933
parent.id,
912934
parent.token,
913935
session=parent._session,
936+
proxy=http.proxy,
937+
proxy_auth=http.proxy_auth,
914938
type=InteractionResponseType.auto_complete_result.value,
915939
data=payload,
916940
)
@@ -938,13 +962,18 @@ async def send_modal(self, modal: Modal) -> Interaction:
938962
if self._responded:
939963
raise InteractionResponded(self._parent)
940964

965+
parent = self._parent
966+
941967
payload = modal.to_dict()
942968
adapter = async_context.get()
969+
http = parent._state.http
943970
await self._locked_response(
944971
adapter.create_interaction_response(
945-
self._parent.id,
946-
self._parent.token,
947-
session=self._parent._session,
972+
parent.id,
973+
parent.token,
974+
session=parent._session,
975+
proxy=http.proxy,
976+
proxy_auth=http.proxy_auth,
948977
type=InteractionResponseType.modal.value,
949978
data=payload,
950979
)

0 commit comments

Comments
 (0)