Browse Source

Add applied_tags param to Webhook.send

pull/10109/head
Andrin 2 years ago
committed by dolfies
parent
commit
1a41d5a381
  1. 7
      discord/http.py
  2. 14
      discord/webhook/async_.py

7
discord/http.py

@ -241,6 +241,7 @@ def handle_message_parameters(
thread_name: str = MISSING,
network_type: NetworkConnectionType = MISSING,
channel_payload: Dict[str, Any] = MISSING,
applied_tags: Optional[SnowflakeList] = MISSING,
) -> MultipartParameters:
if files is not MISSING and file is not MISSING:
raise TypeError('Cannot mix file and files keyword arguments.')
@ -329,6 +330,12 @@ def handle_message_parameters(
payload['attachments'] = attachments_payload
if applied_tags is not MISSING:
if applied_tags is not None:
payload['applied_tags'] = applied_tags
else:
payload['applied_tags'] = []
if channel_payload is not MISSING:
payload = {
'message': payload,

14
discord/webhook/async_.py

@ -45,7 +45,7 @@ from ..asset import Asset
from ..partial_emoji import PartialEmoji
from ..http import Route, handle_message_parameters, json_or_text, HTTPClient
from ..mixins import Hashable
from ..channel import TextChannel, ForumChannel, PartialMessageable
from ..channel import TextChannel, ForumChannel, PartialMessageable, ForumTag
from ..file import File
__all__ = (
@ -85,6 +85,7 @@ if TYPE_CHECKING:
PartialUser as PartialUserPayload,
)
from ..types.emoji import PartialEmoji as PartialEmojiPayload
from ..types.snowflake import SnowflakeList
BE = TypeVar('BE', bound=BaseException)
_State = Union[ConnectionState, '_WebhookState']
@ -1412,6 +1413,7 @@ class Webhook(BaseWebhook):
wait: bool = False,
suppress_embeds: bool = False,
silent: bool = False,
applied_tags: List[ForumTag] = MISSING,
) -> Optional[WebhookMessage]:
"""|coro|
@ -1483,6 +1485,10 @@ class Webhook(BaseWebhook):
in the UI, but will not actually send a notification.
.. versionadded:: 2.0
applied_tags: List[:class:`ForumTag`]
Tags to apply to the thread if the webhook belongs to a :class:`~discord.ForumChannel`.
.. versionadded:: 2.1
Raises
--------
@ -1524,6 +1530,11 @@ class Webhook(BaseWebhook):
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,
@ -1537,6 +1548,7 @@ class Webhook(BaseWebhook):
thread_name=thread_name,
allowed_mentions=allowed_mentions,
previous_allowed_mentions=previous_mentions,
applied_tags=applied_tag_ids,
) as params:
adapter = async_context.get()
thread_id: Optional[int] = None

Loading…
Cancel
Save