Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add applied_tags parameter to Webhook.send() #2322

Merged
merged 5 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ These changes are available on the `master` branch, but have not yet been releas
- Added `default_reaction_emoji` parameter to `Guild.create_forum_channel()` and
`ForumChannel.edit()` methods.
([#2178](https://github.com/Pycord-Development/pycord/pull/2178))
- Added `applied_tags` parameter to `Webhook.send()` method.
([#2322](https://github.com/Pycord-Development/pycord/pull/2322))

### Changed

Expand Down
18 changes: 17 additions & 1 deletion discord/webhook/async_.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ def handle_message_parameters(
embed: Embed | None = MISSING,
embeds: list[Embed] = MISSING,
view: View | None = MISSING,
applied_tags: list[Snowflake] = MISSING,
allowed_mentions: AllowedMentions | None = MISSING,
previous_allowed_mentions: AllowedMentions | None = None,
suppress: bool = False,
Expand Down Expand Up @@ -654,6 +655,9 @@ def handle_message_parameters(
flags = MessageFlags(suppress_embeds=suppress, ephemeral=ephemeral)
payload["flags"] = flags.value

if applied_tags is not MISSING:
payload["applied_tags"] = applied_tags

if allowed_mentions:
if previous_allowed_mentions is not None:
payload["allowed_mentions"] = previous_allowed_mentions.merge(
Expand Down Expand Up @@ -1566,6 +1570,7 @@ async def send(
view: View = MISSING,
thread: Snowflake = MISSING,
thread_name: str | None = None,
applied_tags: list[Snowflake] = MISSING,
wait: Literal[True],
delete_after: float = None,
) -> WebhookMessage:
Expand All @@ -1588,6 +1593,7 @@ async def send(
view: View = MISSING,
thread: Snowflake = MISSING,
thread_name: str | None = None,
applied_tags: list[Snowflake] = MISSING,
wait: Literal[False] = ...,
delete_after: float = None,
) -> None:
Expand All @@ -1609,6 +1615,7 @@ async def send(
view: View = MISSING,
thread: Snowflake = MISSING,
thread_name: str | None = None,
applied_tags: list[Snowflake] = MISSING,
wait: bool = False,
delete_after: float = None,
) -> WebhookMessage | None:
Expand Down Expand Up @@ -1680,6 +1687,10 @@ async def send(
The name of the thread to create. Only works for forum channels.

.. versionadded:: 2.0
applied_tags: List[:class:`Snowflake`]
A list of tags to apply to the message. Only works for threads.

.. versionadded:: 2.5
delete_after: :class:`float`
If provided, the number of seconds to wait in the background
before deleting the message we just sent.
Expand All @@ -1704,7 +1715,8 @@ async def send(
InvalidArgument
Either there was no token associated with this webhook, ``ephemeral`` was passed
with the improper webhook type, there was no state attached with this webhook when
giving it a view, or you specified both ``thread_name`` and ``thread``.
giving it a view, you specified both ``thread_name`` and ``thread``, or ``applied_tags``
was passed with neither ``thread_name`` nor ``thread`` specified.
"""

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

if applied_tags and not (thread or thread_name):
raise InvalidArgument("You cannot specify applied_tags without a thread")

application_webhook = self.type is WebhookType.application
if ephemeral and not application_webhook:
raise InvalidArgument(
Expand Down Expand Up @@ -1749,6 +1764,7 @@ async def send(
embeds=embeds,
ephemeral=ephemeral,
view=view,
applied_tags=applied_tags,
allowed_mentions=allowed_mentions,
previous_allowed_mentions=previous_mentions,
)
Expand Down
Loading