Skip to content

Commit 7efe9a2

Browse files
Paillat-devplun1331Dorukyum
authored
fix: 🐛 TypeError when specifying thread_name in Webhook.send (#2761)
* 🐛 Handle `thread_name` in `handle_message_parameters` to allow sending to thread with multipart * 📝 CHANGELOG.md * Update CHANGELOG.md Co-authored-by: plun1331 <[email protected]> Signed-off-by: Paillat <[email protected]> --------- Signed-off-by: Paillat <[email protected]> Signed-off-by: Paillat <[email protected]> Co-authored-by: plun1331 <[email protected]> Co-authored-by: Dorukyum <[email protected]>
1 parent acf0c7a commit 7efe9a2

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ These changes are available on the `master` branch, but have not yet been releas
106106
- Fixed `ForumChannel.edit` allowing `default_reaction_emoji` to be `None`.
107107
([#2739](https://github.com/Pycord-Development/pycord/pull/2739))
108108
- Fixed missing `None` type hints in `Select.__init__`.
109-
([#2746](https://github.com/Pycord-Development/pycord/pull/2746))
109+
([#2746])(https://github.com/Pycord-Development/pycord/pull/2746)
110+
- Fixed `TypeError` when specifying `thread_name` in `Webhook.send`.
111+
([#2761])(https://github.com/Pycord-Development/pycord/pull/2761)
110112
- Updated `valid_locales` to support `in` and `es-419`.
111113
([#2767](https://github.com/Pycord-Development/pycord/pull/2767))
112114
- Fixed `Webhook.edit` not working with `attachments=[]`.

discord/webhook/async_.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,16 +337,12 @@ def execute_webhook(
337337
multipart: list[dict[str, Any]] | None = None,
338338
files: list[File] | None = None,
339339
thread_id: int | None = None,
340-
thread_name: str | None = None,
341340
wait: bool = False,
342341
) -> Response[MessagePayload | None]:
343342
params = {"wait": int(wait)}
344343
if thread_id:
345344
params["thread_id"] = thread_id
346345

347-
if thread_name:
348-
payload["thread_name"] = thread_name
349-
350346
route = Route(
351347
"POST",
352348
"/webhooks/{webhook_id}/{webhook_token}",
@@ -633,6 +629,7 @@ def handle_message_parameters(
633629
allowed_mentions: AllowedMentions | None = MISSING,
634630
previous_allowed_mentions: AllowedMentions | None = None,
635631
suppress: bool = False,
632+
thread_name: str | None = None,
636633
) -> ExecuteWebhookParameters:
637634
if files is not MISSING and file is not MISSING:
638635
raise TypeError("Cannot mix file and files keyword arguments.")
@@ -717,6 +714,9 @@ def handle_message_parameters(
717714

718715
payload["flags"] = flags.value
719716

717+
if thread_name:
718+
payload["thread_name"] = thread_name
719+
720720
if multipart_files:
721721
multipart.append({"name": "payload_json", "value": utils._to_json(payload)})
722722
payload = None
@@ -1808,6 +1808,7 @@ async def send(
18081808
applied_tags=applied_tags,
18091809
allowed_mentions=allowed_mentions,
18101810
previous_allowed_mentions=previous_mentions,
1811+
thread_name=thread_name,
18111812
)
18121813
adapter = async_context.get()
18131814
thread_id: int | None = None
@@ -1824,7 +1825,6 @@ async def send(
18241825
multipart=params.multipart,
18251826
files=params.files,
18261827
thread_id=thread_id,
1827-
thread_name=thread_name,
18281828
wait=wait,
18291829
)
18301830

discord/webhook/sync.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,16 +307,12 @@ def execute_webhook(
307307
multipart: list[dict[str, Any]] | None = None,
308308
files: list[File] | None = None,
309309
thread_id: int | None = None,
310-
thread_name: str | None = None,
311310
wait: bool = False,
312311
):
313312
params = {"wait": int(wait)}
314313
if thread_id:
315314
params["thread_id"] = thread_id
316315

317-
if thread_name:
318-
payload["thread_name"] = thread_name
319-
320316
route = Route(
321317
"POST",
322318
"/webhooks/{webhook_id}/{webhook_token}",
@@ -1080,6 +1076,7 @@ def send(
10801076
allowed_mentions=allowed_mentions,
10811077
previous_allowed_mentions=previous_mentions,
10821078
suppress=suppress,
1079+
thread_name=thread_name,
10831080
)
10841081
adapter: WebhookAdapter = _get_webhook_adapter()
10851082
thread_id: int | None = None
@@ -1094,7 +1091,6 @@ def send(
10941091
multipart=params.multipart,
10951092
files=params.files,
10961093
thread_id=thread_id,
1097-
thread_name=thread_name,
10981094
wait=wait,
10991095
)
11001096
if wait:

0 commit comments

Comments
 (0)