Skip to content

Commit 3e534b7

Browse files
LulalabyJustaSqu1d
andauthored
feat: voice message support (#2016)
Co-authored-by: JustaSqu1d <[email protected]> Signed-off-by: Lala Sabathil <[email protected]>
1 parent 3847a8c commit 3e534b7

File tree

5 files changed

+38
-2
lines changed

5 files changed

+38
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ These changes are available on the `master` branch, but have not yet been releas
3030
- Added new `application_auto_moderation_rule_create_badge` to `ApplicationFlags`.
3131
([#1992](https://github.com/Pycord-Development/pycord/pull/1992))
3232
- Added `custom_message` to AutoModActionMetadata.
33-
- ([#2029](https://github.com/Pycord-Development/pycord/pull/2029))
33+
([#2029](https://github.com/Pycord-Development/pycord/pull/2029))
34+
- Added support for
35+
[voice messages](https://github.com/discord/discord-api-docs/pull/6082).
36+
([#2016](https://github.com/Pycord-Development/pycord/pull/2016))
3437

3538
### Changed
3639

discord/flags.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,14 @@ def suppress_notifications(self):
404404

405405
return 4096
406406

407+
@flag_value
408+
def is_voice_message(self):
409+
""":class:`bool`: Returns ``True`` if this message is a voice message.
410+
411+
.. versionadded:: 2.5
412+
"""
413+
return 8192
414+
407415

408416
@fill_with_flags()
409417
class PublicUserFlags(BaseFlags):

discord/message.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class Attachment(Hashable):
159159
case of images. When the message is deleted, this URL might be valid for a few
160160
minutes or not valid at all.
161161
content_type: Optional[:class:`str`]
162-
The attachment's `media type <https://en.wikipedia.org/wiki/Media_type>`_
162+
The attachment's `media type <https://en.wikipedia.org/wiki/Media_type>`_.
163163
ephemeral: :class:`bool`
164164
Whether the attachment is ephemeral or not.
165165
@@ -169,6 +169,16 @@ class Attachment(Hashable):
169169
The attachment's description.
170170
171171
.. versionadded:: 2.0
172+
173+
duration_secs: Optional[:class:`float`]
174+
The duration of the audio file (currently for voice messages).
175+
176+
.. versionadded:: 2.5
177+
178+
waveform: Optional[:class:`str`]
179+
The base64 encoded bytearray representing a sampled waveform (currently for voice messages).
180+
181+
.. versionadded:: 2.5
172182
"""
173183

174184
__slots__ = (
@@ -183,6 +193,8 @@ class Attachment(Hashable):
183193
"content_type",
184194
"ephemeral",
185195
"description",
196+
"duration_secs",
197+
"waveform",
186198
)
187199

188200
def __init__(self, *, data: AttachmentPayload, state: ConnectionState):
@@ -197,6 +209,8 @@ def __init__(self, *, data: AttachmentPayload, state: ConnectionState):
197209
self.content_type: str | None = data.get("content_type")
198210
self.ephemeral: bool = data.get("ephemeral", False)
199211
self.description: str | None = data.get("description")
212+
self.duration_secs: float | None = data.get("duration_secs")
213+
self.waveform: str | None = data.get("waveform")
200214

201215
def is_spoiler(self) -> bool:
202216
"""Whether this attachment contains a spoiler."""

discord/permissions.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,14 @@ def moderate_members(self) -> int:
610610
"""
611611
return 1 << 40
612612

613+
@flag_value
614+
def send_voice_messages(self) -> int:
615+
""":class:`bool`: Returns ``True`` if a member can send voice messages.
616+
617+
.. versionadded:: 2.5
618+
"""
619+
return 1 << 46
620+
613621

614622
PO = TypeVar("PO", bound="PermissionOverwrite")
615623

@@ -727,6 +735,7 @@ class PermissionOverwrite:
727735
use_external_stickers: bool | None
728736
start_embedded_activities: bool | None
729737
moderate_members: bool | None
738+
send_voice_messages: bool | None
730739

731740
def __init__(self, **kwargs: bool | None):
732741
self._values: dict[str, bool | None] = {}

discord/types/message.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class Attachment(TypedDict):
6666
size: int
6767
url: str
6868
proxy_url: str
69+
duration_secs: NotRequired[float]
70+
waveform: NotRequired[str]
6971

7072

7173
MessageActivityType = Literal[1, 2, 3, 5]

0 commit comments

Comments
 (0)