Skip to content

Commit 7f6b0c8

Browse files
authored
Merge branch 'master' into feat-media-channels
Signed-off-by: Paillat <[email protected]>
2 parents 3aeebfd + f107660 commit 7f6b0c8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+393
-145
lines changed

.github/workflows/docs-localization-download.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
working-directory: ./docs
4141
- name: "Crowdin"
4242
id: crowdin
43-
uses: crowdin/github-action@v2
43+
uses: crowdin/github-action@v2.5.0
4444
with:
4545
upload_sources: false
4646
upload_translations: false

.github/workflows/docs-localization-upload.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
sphinx-intl update -p ./build/locales ${{ vars.SPHINX_LANGUAGES }}
4545
working-directory: ./docs
4646
- name: "Crowdin"
47-
uses: crowdin/github-action@v2
47+
uses: crowdin/github-action@v2.5.0
4848
with:
4949
upload_sources: true
5050
upload_translations: false

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ repos:
2121
# - --remove-duplicate-keys
2222
# - --remove-unused-variables
2323
- repo: https://github.com/asottile/pyupgrade
24-
rev: v3.19.0
24+
rev: v3.19.1
2525
hooks:
2626
- id: pyupgrade
2727
exclude: \.(po|pot|yml|yaml)$

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ These changes are available on the `master` branch, but have not yet been releas
3030
([#2587](https://github.com/Pycord-Development/pycord/pull/2587/))
3131
- Added optional `filter` parameter to `utils.basic_autocomplete()`.
3232
([#2590](https://github.com/Pycord-Development/pycord/pull/2590))
33+
- Added role tags: `subscription_listing_id`, `guild_connections`, and
34+
`available_for_purchase`.
35+
([#2606](https://github.com/Pycord-Development/pycord/pull/2606))
3336
- Added missing `with_counts` parameter to `fetch_guilds` method.
3437
([#2615](https://github.com/Pycord-Development/pycord/pull/2615))
3538
- Added the following missing permissions: `Permissions.use_soundboard`,
@@ -38,6 +41,12 @@ These changes are available on the `master` branch, but have not yet been releas
3841
([#2620](https://github.com/Pycord-Development/pycord/pull/2620))
3942
- Added `MediaChannel` channel type.
4043
([#2641](https://github.com/Pycord-Development/pycord/pull/2641))
44+
- Added `Message._raw_data` attribute.
45+
([#2670](https://github.com/Pycord-Development/pycord/pull/2670))
46+
- Added helper methods to determine the authorizing party of an `Interaction`.
47+
([#2659](https://github.com/Pycord-Development/pycord/pull/2659))
48+
- Added `VoiceMessage` subclass of `File` to allow voice messages to be sent.
49+
([#2579](https://github.com/Pycord-Development/pycord/pull/2579))
4150

4251
### Fixed
4352

@@ -68,6 +77,12 @@ These changes are available on the `master` branch, but have not yet been releas
6877
apps. ([#2650](https://github.com/Pycord-Development/pycord/pull/2650))
6978
- Fixed type annotations of cached properties.
7079
([#2635](https://github.com/Pycord-Development/pycord/issues/2635))
80+
- Fixed an error when responding non-ephemerally with a `Paginator` to an ephemerally
81+
deferred interaction.
82+
([#2661](https://github.com/Pycord-Development/pycord/pull/2661))
83+
- Fixed attachment metadata being set incorrectly in interaction responses causing the
84+
metadata to be ignored by Discord.
85+
([#2679](https://github.com/Pycord-Development/pycord/pull/2679))
7186

7287
### Changed
7388

@@ -81,6 +96,8 @@ These changes are available on the `master` branch, but have not yet been releas
8196
- Replaced audioop (deprecated module) implementation of `PCMVolumeTransformer.read`
8297
method with a pure Python equivalent.
8398
([#2176](https://github.com/Pycord-Development/pycord/pull/2176))
99+
- Updated `Guild.filesize_limit` to 10 MB instead of 25 MB following Discord's API
100+
changes. ([#2671](https://github.com/Pycord-Development/pycord/pull/2671))
84101

85102
### Deprecated
86103

discord/_typed_dict.py

Lines changed: 0 additions & 38 deletions
This file was deleted.

discord/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import warnings
3131
from importlib.metadata import PackageNotFoundError, version
3232

33-
from ._typed_dict import TypedDict
33+
from typing_extensions import TypedDict
3434

3535
__all__ = ("__version__", "VersionInfo", "version_info")
3636

discord/abc.py

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
from .context_managers import Typing
4747
from .enums import ChannelType
4848
from .errors import ClientException, InvalidArgument
49-
from .file import File
49+
from .file import File, VoiceMessage
5050
from .flags import ChannelFlags, MessageFlags
5151
from .invite import Invite
5252
from .iterators import HistoryIterator
@@ -1566,7 +1566,7 @@ async def send(
15661566
flags = MessageFlags(
15671567
suppress_embeds=bool(suppress),
15681568
suppress_notifications=bool(silent),
1569-
).value
1569+
)
15701570

15711571
if stickers is not None:
15721572
stickers = [sticker.id for sticker in stickers]
@@ -1612,27 +1612,7 @@ async def send(
16121612
if file is not None:
16131613
if not isinstance(file, File):
16141614
raise InvalidArgument("file parameter must be File")
1615-
1616-
try:
1617-
data = await state.http.send_files(
1618-
channel.id,
1619-
files=[file],
1620-
allowed_mentions=allowed_mentions,
1621-
content=content,
1622-
tts=tts,
1623-
embed=embed,
1624-
embeds=embeds,
1625-
nonce=nonce,
1626-
enforce_nonce=enforce_nonce,
1627-
message_reference=reference,
1628-
stickers=stickers,
1629-
components=components,
1630-
flags=flags,
1631-
poll=poll,
1632-
)
1633-
finally:
1634-
file.close()
1635-
1615+
files = [file]
16361616
elif files is not None:
16371617
if len(files) > 10:
16381618
raise InvalidArgument(
@@ -1641,6 +1621,10 @@ async def send(
16411621
elif not all(isinstance(file, File) for file in files):
16421622
raise InvalidArgument("files parameter must be a list of File")
16431623

1624+
if files is not None:
1625+
flags = flags + MessageFlags(
1626+
is_voice_message=any(isinstance(f, VoiceMessage) for f in files)
1627+
)
16441628
try:
16451629
data = await state.http.send_files(
16461630
channel.id,
@@ -1655,7 +1639,7 @@ async def send(
16551639
message_reference=reference,
16561640
stickers=stickers,
16571641
components=components,
1658-
flags=flags,
1642+
flags=flags.value,
16591643
poll=poll,
16601644
)
16611645
finally:
@@ -1674,7 +1658,7 @@ async def send(
16741658
message_reference=reference,
16751659
stickers=stickers,
16761660
components=components,
1677-
flags=flags,
1661+
flags=flags.value,
16781662
poll=poll,
16791663
)
16801664

discord/commands/context.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,40 @@ def cog(self) -> Cog | None:
345345

346346
return self.command.cog
347347

348+
def is_guild_authorised(self) -> bool:
349+
""":class:`bool`: Checks if the invoked command is guild-installed.
350+
This is a shortcut for :meth:`Interaction.is_guild_authorised`.
351+
352+
There is an alias for this called :meth:`.is_guild_authorized`.
353+
354+
.. versionadded:: 2.7
355+
"""
356+
return self.interaction.is_guild_authorised()
357+
358+
def is_user_authorised(self) -> bool:
359+
""":class:`bool`: Checks if the invoked command is user-installed.
360+
This is a shortcut for :meth:`Interaction.is_user_authorised`.
361+
362+
There is an alias for this called :meth:`.is_user_authorized`.
363+
364+
.. versionadded:: 2.7
365+
"""
366+
return self.interaction.is_user_authorised()
367+
368+
def is_guild_authorized(self) -> bool:
369+
""":class:`bool`: An alias for :meth:`.is_guild_authorised`.
370+
371+
.. versionadded:: 2.7
372+
"""
373+
return self.is_guild_authorised()
374+
375+
def is_user_authorized(self) -> bool:
376+
""":class:`bool`: An alias for :meth:`.is_user_authorised`.
377+
378+
.. versionadded:: 2.7
379+
"""
380+
return self.is_user_authorised()
381+
348382

349383
class AutocompleteContext:
350384
"""Represents context for a slash command's option autocomplete.

discord/ext/pages/pagination.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ async def respond(
12021202
)
12031203
# convert from WebhookMessage to Message reference to bypass
12041204
# 15min webhook token timeout (non-ephemeral messages only)
1205-
if not ephemeral:
1205+
if not ephemeral and not msg.flags.ephemeral:
12061206
msg = await msg.channel.fetch_message(msg.id)
12071207
else:
12081208
msg = await interaction.response.send_message(

discord/file.py

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
import os
3030
from typing import TYPE_CHECKING
3131

32-
__all__ = ("File",)
32+
__all__ = (
33+
"File",
34+
"VoiceMessage",
35+
)
3336

3437

3538
class File:
@@ -89,6 +92,7 @@ def __init__(
8992
description: str | None = None,
9093
spoiler: bool = False,
9194
):
95+
9296
if isinstance(fp, io.IOBase):
9397
if not (fp.seekable() and fp.readable()):
9498
raise ValueError(f"File buffer {fp!r} must be seekable and readable")
@@ -143,3 +147,60 @@ def close(self) -> None:
143147
self.fp.close = self._closer
144148
if self._owner:
145149
self._closer()
150+
151+
152+
class VoiceMessage(File):
153+
"""A special case of the File class that represents a voice message.
154+
155+
.. versionadded:: 2.7
156+
157+
.. note::
158+
159+
Similar to File objects, VoiceMessage objects are single use and are not meant to be reused in
160+
multiple requests.
161+
162+
Attributes
163+
----------
164+
fp: Union[:class:`os.PathLike`, :class:`io.BufferedIOBase`]
165+
A audio file-like object opened in binary mode and read mode
166+
or a filename representing a file in the hard drive to
167+
open.
168+
169+
.. note::
170+
171+
If the file-like object passed is opened via ``open`` then the
172+
modes 'rb' should be used.
173+
174+
To pass binary data, consider usage of ``io.BytesIO``.
175+
176+
filename: Optional[:class:`str`]
177+
The filename to display when uploading to Discord.
178+
If this is not given then it defaults to ``fp.name`` or if ``fp`` is
179+
a string then the ``filename`` will default to the string given.
180+
description: Optional[:class:`str`]
181+
The description of a file, used by Discord to display alternative text on images.
182+
spoiler: :class:`bool`
183+
Whether the attachment is a spoiler.
184+
waveform: Optional[:class:`str`]
185+
The base64 encoded bytearray representing a sampled waveform.
186+
duration_secs: Optional[:class:`float`]
187+
The duration of the voice message.
188+
"""
189+
190+
__slots__ = (
191+
"waveform",
192+
"duration_secs",
193+
)
194+
195+
def __init__(
196+
self,
197+
fp: str | bytes | os.PathLike | io.BufferedIOBase,
198+
filename: str | None = None,
199+
*,
200+
waveform: str = "",
201+
duration_secs: float = 0.0,
202+
**kwargs,
203+
):
204+
super().__init__(fp, filename, **kwargs)
205+
self.waveform = waveform
206+
self.duration_secs = duration_secs

0 commit comments

Comments
 (0)