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
Changes from 1 commit
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
Next Next commit
added support for webhook applied_tags
  • Loading branch information
tyrantlink authored and Lulalaby committed Jan 22, 2024
commit e4104316435d27b5a2a27cb9fe70d5d980060e9e
15 changes: 15 additions & 0 deletions 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: [Snowflake] = MISSING,
tyrantlink marked this conversation as resolved.
Show resolved Hide resolved
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: [Snowflake] = MISSING,
tyrantlink marked this conversation as resolved.
Show resolved Hide resolved
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: [Snowflake] = MISSING,
tyrantlink marked this conversation as resolved.
Show resolved Hide resolved
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: [Snowflake] = MISSING,
tyrantlink marked this conversation as resolved.
Show resolved Hide resolved
wait: bool = False,
delete_after: float = None,
) -> WebhookMessage | None:
Expand Down Expand Up @@ -1679,6 +1686,10 @@ async def send(
thread_name: :class:`str`
The name of the thread to create. Only works for forum channels.

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

Dorukyum marked this conversation as resolved.
Show resolved Hide resolved
.. versionadded:: 2.0
delete_after: :class:`float`
If provided, the number of seconds to wait in the background
Expand Down Expand Up @@ -1721,6 +1732,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 +1763,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