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

Webhook.send voice_message param #9459

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 9 additions & 1 deletion discord/webhook/async_.py
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,7 @@ async def send(
wait: Literal[True],
suppress_embeds: bool = MISSING,
silent: bool = MISSING,
voice_message: bool = MISSING,
) -> WebhookMessage:
...

Expand All @@ -1617,6 +1618,7 @@ async def send(
wait: Literal[False] = ...,
suppress_embeds: bool = MISSING,
silent: bool = MISSING,
voice_message: bool = MISSING,
) -> None:
...

Expand All @@ -1639,6 +1641,7 @@ async def send(
wait: bool = False,
suppress_embeds: bool = False,
silent: bool = False,
voice_message: bool = False,
) -> Optional[WebhookMessage]:
"""|coro|

Expand Down Expand Up @@ -1724,6 +1727,10 @@ async def send(
in the UI, but will not actually send a notification.

.. versionadded:: 2.2
voice_message: :class:`bool`
Whether to send this message as a voice message. This will only work with audio files.

.. versionadded:: 2.3

Raises
--------
Expand Down Expand Up @@ -1754,11 +1761,12 @@ async def send(
previous_mentions: Optional[AllowedMentions] = getattr(self._state, 'allowed_mentions', None)
if content is None:
content = MISSING
if ephemeral or suppress_embeds or silent:
if ephemeral or suppress_embeds or silent or voice_message:
flags = MessageFlags._from_value(0)
flags.ephemeral = ephemeral
flags.suppress_embeds = suppress_embeds
flags.suppress_notifications = silent
flags.voice = voice_message
else:
flags = MISSING

Expand Down
10 changes: 9 additions & 1 deletion discord/webhook/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,7 @@ def send(
wait: Literal[True],
suppress_embeds: bool = MISSING,
silent: bool = MISSING,
voice_message: bool = MISSING,
) -> SyncWebhookMessage:
...

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

Expand All @@ -911,6 +913,7 @@ def send(
wait: bool = False,
suppress_embeds: bool = False,
silent: bool = False,
voice_message: bool = False,
) -> Optional[SyncWebhookMessage]:
"""Sends a message using the webhook.

Expand Down Expand Up @@ -975,6 +978,10 @@ def send(
in the UI, but will not actually send a notification.

.. versionadded:: 2.2
voice_message: :class:`bool`
Whether to send this message as a voice message. This will only work with audio files.

.. versionadded:: 2.3

Raises
--------
Expand Down Expand Up @@ -1004,10 +1011,11 @@ def send(
if content is None:
content = MISSING

if suppress_embeds or silent:
if suppress_embeds or silent or voice_message:
flags = MessageFlags._from_value(0)
flags.suppress_embeds = suppress_embeds
flags.suppress_notifications = silent
flags.voice = voice_message
else:
flags = MISSING

Expand Down