From 5644c82df711fd663373944190976aeb6826c372 Mon Sep 17 00:00:00 2001 From: nmsturcke <30734036+nmsturcke@users.noreply.github.com> Date: Wed, 21 Jun 2023 21:01:59 +0200 Subject: [PATCH 1/2] Create voice_message field in Webhook.send --- discord/webhook/async_.py | 6 +++++- discord/webhook/sync.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/discord/webhook/async_.py b/discord/webhook/async_.py index 9ce18bbe49d8..98cdf0b33f55 100644 --- a/discord/webhook/async_.py +++ b/discord/webhook/async_.py @@ -1594,6 +1594,7 @@ async def send( wait: Literal[True], suppress_embeds: bool = MISSING, silent: bool = MISSING, + voice_message: bool = MISSING, ) -> WebhookMessage: ... @@ -1617,6 +1618,7 @@ async def send( wait: Literal[False] = ..., suppress_embeds: bool = MISSING, silent: bool = MISSING, + voice_message: bool = MISSING, ) -> None: ... @@ -1639,6 +1641,7 @@ async def send( wait: bool = False, suppress_embeds: bool = False, silent: bool = False, + voice_message: bool = False, ) -> Optional[WebhookMessage]: """|coro| @@ -1754,11 +1757,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 diff --git a/discord/webhook/sync.py b/discord/webhook/sync.py index 7da6ada70818..abba42e3b21a 100644 --- a/discord/webhook/sync.py +++ b/discord/webhook/sync.py @@ -870,6 +870,7 @@ def send( wait: Literal[True], suppress_embeds: bool = MISSING, silent: bool = MISSING, + voice_message: bool = MISSING, ) -> SyncWebhookMessage: ... @@ -891,6 +892,7 @@ def send( wait: Literal[False] = ..., suppress_embeds: bool = MISSING, silent: bool = MISSING, + voice_message: bool = MISSING, ) -> None: ... @@ -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. @@ -1004,10 +1007,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 From dc38b896a8bd39488c03742fae5b523e484f39f8 Mon Sep 17 00:00:00 2001 From: nmsturcke <30734036+nmsturcke@users.noreply.github.com> Date: Wed, 21 Jun 2023 21:22:12 +0200 Subject: [PATCH 2/2] Document it --- discord/webhook/async_.py | 4 ++++ discord/webhook/sync.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/discord/webhook/async_.py b/discord/webhook/async_.py index 98cdf0b33f55..19bf408ccfd8 100644 --- a/discord/webhook/async_.py +++ b/discord/webhook/async_.py @@ -1727,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 -------- diff --git a/discord/webhook/sync.py b/discord/webhook/sync.py index abba42e3b21a..dc2d99149f33 100644 --- a/discord/webhook/sync.py +++ b/discord/webhook/sync.py @@ -978,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 --------