Skip to content

Commit

Permalink
Add support for applied_tags in Webhook.send overloaded methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Vioshim committed Apr 18, 2024
1 parent f1a19f2 commit 5497674
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions discord/webhook/async_.py
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,7 @@ async def send(
wait: Literal[True],
suppress_embeds: bool = MISSING,
silent: bool = MISSING,
applied_tags: List[ForumTag] = MISSING,
) -> WebhookMessage:
...

Expand All @@ -1619,6 +1620,7 @@ async def send(
wait: Literal[False] = ...,
suppress_embeds: bool = MISSING,
silent: bool = MISSING,
applied_tags: List[ForumTag] = MISSING,
) -> None:
...

Expand Down
12 changes: 11 additions & 1 deletion discord/webhook/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from ..errors import HTTPException, Forbidden, NotFound, DiscordServerError
from ..message import Message, MessageFlags
from ..http import Route, handle_message_parameters
from ..channel import PartialMessageable
from ..channel import PartialMessageable, ForumTag

from .async_ import BaseWebhook, _WebhookState

Expand All @@ -71,6 +71,7 @@
from ..types.message import (
Message as MessagePayload,
)
from ..types.snowflake import SnowflakeList

BE = TypeVar('BE', bound=BaseException)

Expand Down Expand Up @@ -870,6 +871,7 @@ def send(
wait: Literal[True],
suppress_embeds: bool = MISSING,
silent: bool = MISSING,
applied_tags: List[ForumTag] = MISSING,
) -> SyncWebhookMessage:
...

Expand All @@ -891,6 +893,7 @@ def send(
wait: Literal[False] = ...,
suppress_embeds: bool = MISSING,
silent: bool = MISSING,
applied_tags: List[ForumTag] = MISSING,
) -> None:
...

Expand All @@ -911,6 +914,7 @@ def send(
wait: bool = False,
suppress_embeds: bool = False,
silent: bool = False,
applied_tags: List[ForumTag] = MISSING,
) -> Optional[SyncWebhookMessage]:
"""Sends a message using the webhook.
Expand Down Expand Up @@ -1014,6 +1018,11 @@ def send(
if thread_name is not MISSING and thread is not MISSING:
raise TypeError('Cannot mix thread_name and thread keyword arguments.')

if applied_tags is MISSING:
applied_tag_ids = MISSING
else:
applied_tag_ids: SnowflakeList = [tag.id for tag in applied_tags]

with handle_message_parameters(
content=content,
username=username,
Expand All @@ -1027,6 +1036,7 @@ def send(
allowed_mentions=allowed_mentions,
previous_allowed_mentions=previous_mentions,
flags=flags,
applied_tags=applied_tag_ids,
) as params:
adapter: WebhookAdapter = _get_webhook_adapter()
thread_id: Optional[int] = None
Expand Down

0 comments on commit 5497674

Please sign in to comment.