Skip to content

Commit 9422439

Browse files
tyrantlinkDorukyum
andauthored
feat: add applied_tags parameter to Webhook.send (Pycord-Development#2322)
* added support for webhook applied_tags * update changelog * am a dummy forgot about half the typehinting * docs: fix versionadded * docs: update exception cases --------- Co-authored-by: Dorukyum <[email protected]>
1 parent 122cf46 commit 9422439

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ These changes are available on the `master` branch, but have not yet been releas
8282
- Added `default_reaction_emoji` parameter to `Guild.create_forum_channel()` and
8383
`ForumChannel.edit()` methods.
8484
([#2178](https://github.com/Pycord-Development/pycord/pull/2178))
85+
- Added `applied_tags` parameter to `Webhook.send()` method.
86+
([#2322](https://github.com/Pycord-Development/pycord/pull/2322))
8587

8688
### Changed
8789

discord/webhook/async_.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ def handle_message_parameters(
621621
embed: Embed | None = MISSING,
622622
embeds: list[Embed] = MISSING,
623623
view: View | None = MISSING,
624+
applied_tags: list[Snowflake] = MISSING,
624625
allowed_mentions: AllowedMentions | None = MISSING,
625626
previous_allowed_mentions: AllowedMentions | None = None,
626627
suppress: bool = False,
@@ -654,6 +655,9 @@ def handle_message_parameters(
654655
flags = MessageFlags(suppress_embeds=suppress, ephemeral=ephemeral)
655656
payload["flags"] = flags.value
656657

658+
if applied_tags is not MISSING:
659+
payload["applied_tags"] = applied_tags
660+
657661
if allowed_mentions:
658662
if previous_allowed_mentions is not None:
659663
payload["allowed_mentions"] = previous_allowed_mentions.merge(
@@ -1566,6 +1570,7 @@ async def send(
15661570
view: View = MISSING,
15671571
thread: Snowflake = MISSING,
15681572
thread_name: str | None = None,
1573+
applied_tags: list[Snowflake] = MISSING,
15691574
wait: Literal[True],
15701575
delete_after: float = None,
15711576
) -> WebhookMessage:
@@ -1588,6 +1593,7 @@ async def send(
15881593
view: View = MISSING,
15891594
thread: Snowflake = MISSING,
15901595
thread_name: str | None = None,
1596+
applied_tags: list[Snowflake] = MISSING,
15911597
wait: Literal[False] = ...,
15921598
delete_after: float = None,
15931599
) -> None:
@@ -1609,6 +1615,7 @@ async def send(
16091615
view: View = MISSING,
16101616
thread: Snowflake = MISSING,
16111617
thread_name: str | None = None,
1618+
applied_tags: list[Snowflake] = MISSING,
16121619
wait: bool = False,
16131620
delete_after: float = None,
16141621
) -> WebhookMessage | None:
@@ -1680,6 +1687,10 @@ async def send(
16801687
The name of the thread to create. Only works for forum channels.
16811688
16821689
.. versionadded:: 2.0
1690+
applied_tags: List[:class:`Snowflake`]
1691+
A list of tags to apply to the message. Only works for threads.
1692+
1693+
.. versionadded:: 2.5
16831694
delete_after: :class:`float`
16841695
If provided, the number of seconds to wait in the background
16851696
before deleting the message we just sent.
@@ -1704,7 +1715,8 @@ async def send(
17041715
InvalidArgument
17051716
Either there was no token associated with this webhook, ``ephemeral`` was passed
17061717
with the improper webhook type, there was no state attached with this webhook when
1707-
giving it a view, or you specified both ``thread_name`` and ``thread``.
1718+
giving it a view, you specified both ``thread_name`` and ``thread``, or ``applied_tags``
1719+
was passed with neither ``thread_name`` nor ``thread`` specified.
17081720
"""
17091721

17101722
if self.token is None:
@@ -1721,6 +1733,9 @@ async def send(
17211733
if thread and thread_name:
17221734
raise InvalidArgument("You cannot specify both a thread and thread_name")
17231735

1736+
if applied_tags and not (thread or thread_name):
1737+
raise InvalidArgument("You cannot specify applied_tags without a thread")
1738+
17241739
application_webhook = self.type is WebhookType.application
17251740
if ephemeral and not application_webhook:
17261741
raise InvalidArgument(
@@ -1749,6 +1764,7 @@ async def send(
17491764
embeds=embeds,
17501765
ephemeral=ephemeral,
17511766
view=view,
1767+
applied_tags=applied_tags,
17521768
allowed_mentions=allowed_mentions,
17531769
previous_allowed_mentions=previous_mentions,
17541770
)

0 commit comments

Comments
 (0)