Skip to content

Commit 347f78a

Browse files
Paillat-devLulalabypre-commit-ci[bot]NeloBlivionDA-344
authored
chore: 🔃 Merge upstream (#147)
Co-authored-by: Lala Sabathil <lala@pycord.dev> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: UK <41271523+NeloBlivion@users.noreply.github.com> Co-authored-by: Paillat <me@paillat.dev> Co-authored-by: DA344 <108473820+DA-344@users.noreply.github.com> Co-authored-by: plun1331 <plun1331@gmail.com> Co-authored-by: JustaSqu1d <89910983+JustaSqu1d@users.noreply.github.com> Co-authored-by: Paillat <paillat@pycord.dev> Co-authored-by: Lala Sabathil <aiko@aitsys.dev> Co-authored-by: Paillat <jeremiecotti@ik.me> Co-authored-by: Lumouille <144063653+Lumabots@users.noreply.github.com> Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Dasupergrasskakjd <ethankahoot302@gmail.com> Co-authored-by: Soheab <33902984+Soheab@users.noreply.github.com> Co-authored-by: UK <41271523+neloblivion@users.noreply.github.com> Co-authored-by: JL710 <git@jl710.de> Co-authored-by: BOXER <130167557+boxerrmd@users.noreply.github.com> Co-authored-by: Lumouille <144063653+lumabots@users.noreply.github.com> Co-authored-by: Ice Wolfy <44532864+icebluewolf@users.noreply.github.com>
1 parent 5ec87c5 commit 347f78a

Some content is hidden

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

47 files changed

+2098
-167
lines changed

.github/SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
| Version | Supported |
66
| ------- | ------------------ |
77
| 2.x | :white_check_mark: |
8-
| <2.0.0 | :x: |
8+
| <2.6.1 | :x: |
99

1010
## Reporting a Vulnerability
1111

CHANGELOG.md

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,46 @@ possible (see our [Version Guarantees] for more info).
1010

1111
These changes are available on the `master` branch, but have not yet been released.
1212

13+
### Added
14+
15+
- Implemented `with_response` for interaction callbacks, adding
16+
`Interaction.callback.is_loading()` and `Interaction.callback.is_ephemeral()`.
17+
([#2711](https://github.com/Pycord-Development/pycord/pull/2711))
18+
- Added `RawMessageUpdateEvent.new_message` - message update events now contain full
19+
message objects ([#2780](https://github.com/Pycord-Development/pycord/pull/2780))
20+
- Added support for setting guild-specific `avatar`, `banner`, and `bio` for the bot
21+
user through `Member.edit`.
22+
([#2908](https://github.com/Pycord-Development/pycord/pull/2908))
23+
- Added support for select default values.
24+
([#2899](https://github.com/Pycord-Development/pycord/pull/2899))
25+
- Adds a new generic parameter to selects to type `ui.Select.values` return type.
26+
- Adds `SelectDefaultValue` object to create select default values.
27+
- Adds `SelectDefaultValueType` enum.
28+
- Adds pre-typed and pre-constructed with select_type `ui.Select` aliases for the
29+
different select types: `ui.StringSelect`, `ui.UserSelect`, `ui.RoleSelect`,
30+
`ui.MentionableSelect`, and `ui.ChannelSelect`.
31+
32+
### Changed
33+
34+
### Fixed
35+
36+
- Manage silence for new SSRC with existing user_id.
37+
([#2808](https://github.com/Pycord-Development/pycord/pull/2808))
38+
- Unbound `raw` reference in `parse_message_update` causing errors on message updates.
39+
([#2905](https://github.com/Pycord-Development/pycord/pull/2905))
40+
- `view=None` in various methods causing an AttributeError.
41+
([#2915](https://github.com/Pycord-Development/pycord/pull/2915))
42+
- `View.message` being `None` when it had not been interacted with yet.
43+
([#2916](https://github.com/Pycord-Development/pycord/pull/2916))
44+
- Fixed a crash when processing message edit events while message cache was disabled.
45+
([#2924](https://github.com/Pycord-Development/pycord/pull/2924))
46+
- Fixed OPUS Decode Error when recording audio.
47+
([#2925](https://github.com/Pycord-Development/pycord/pull/2925))
48+
49+
### Removed
50+
51+
## [2.7.0rc1] - 2025-08-30
52+
1353
⚠️ **This version removes support for Python 3.8.** ⚠️
1454

1555
### Added
@@ -47,6 +87,15 @@ These changes are available on the `master` branch, but have not yet been releas
4787
([#2659](https://github.com/Pycord-Development/pycord/pull/2659))
4888
- Added `VoiceMessage` subclass of `File` to allow voice messages to be sent.
4989
([#2579](https://github.com/Pycord-Development/pycord/pull/2579))
90+
- Added the following soundboard-related features:
91+
- Manage guild soundboard sounds with `Guild.fetch_sounds()`, `Guild.create_sound()`,
92+
`SoundboardSound.edit()`, and `SoundboardSound.delete()`.
93+
- Access Discord default sounds with `Client.fetch_default_sounds()`.
94+
- Play sounds in voice channels with `VoiceChannel.send_soundboard_sound()`.
95+
- New `on_voice_channel_effect_send` event for sound and emoji effects.
96+
- Soundboard limits based on guild premium tier (8-48 slots) in
97+
`Guild.soundboard_limit`.
98+
([#2623](https://github.com/Pycord-Development/pycord/pull/2623))
5099
- Added new `Subscription` object and related methods/events.
51100
([#2564](https://github.com/Pycord-Development/pycord/pull/2564))
52101
- Added `Message.forward_to`, `Message.snapshots`, and other related attributes.
@@ -57,6 +106,8 @@ These changes are available on the `master` branch, but have not yet been releas
57106
([#2714](https://github.com/Pycord-Development/pycord/pull/2714))
58107
- Added the ability to pass a `datetime.time` object to `format_dt`.
59108
([#2747](https://github.com/Pycord-Development/pycord/pull/2747))
109+
- Added various missing channel parameters and allow `default_reaction_emoji` to be
110+
`None`. ([#2772](https://github.com/Pycord-Development/pycord/pull/2772))
60111
- Added support for type hinting slash command options with `typing.Annotated`.
61112
([#2782](https://github.com/Pycord-Development/pycord/pull/2782))
62113
- Added conversion to `Member` in `MentionableConverter`.
@@ -67,8 +118,18 @@ These changes are available on the `master` branch, but have not yet been releas
67118
([#2817](https://github.com/Pycord-Development/pycord/pull/2817))
68119
- Added role gradients support with `Role.colours` and the `RoleColours` class.
69120
([#2818](https://github.com/Pycord-Development/pycord/pull/2818))
121+
- Added `ThreadArchiveDuration` enum to improve clarity of thread archive durations.
122+
([#2826](https://github.com/Pycord-Development/pycord/pull/2826))
70123
- Added `Interaction.attachment_size_limit`.
71124
([#2854](https://github.com/Pycord-Development/pycord/pull/2854))
125+
- Added support for selects and text displays in modals.
126+
([#2858](https://github.com/Pycord-Development/pycord/pull/2858))
127+
- Added `AuditLogDiff.communication_disabled_until`.
128+
([#2883](https://github.com/Pycord-Development/pycord/pull/2883))
129+
- Added `discord.User.primary_guild` and the `PrimaryGuild` class.
130+
([#2876](https://github.com/Pycord-Development/pycord/pull/2876))
131+
- Added `get_component` to `Message`, `Section`, `Container` and `ActionRow`.
132+
([#2849](https://github.com/Pycord-Development/pycord/pull/2849))
72133

73134
### Fixed
74135

@@ -140,6 +201,15 @@ These changes are available on the `master` branch, but have not yet been releas
140201
([#2843](https://github.com/Pycord-Development/pycord/pull/2843))
141202
- Fixed `TypeError` when using `@option` with certain annotations and along with
142203
`channel_types`. ([#2835](https://github.com/Pycord-Development/pycord/pull/2835))
204+
- Fixed `TypeError` when using `Optional[...]` or `... | None` in command option type.
205+
([#2852](https://github.com/Pycord-Development/pycord/pull/2852))
206+
- Fixed type-hinting for `PermissionOverwrite.update`.
207+
([#2878](https://github.com/Pycord-Development/pycord/pull/2878))
208+
- Fixed `AttributeError` when accessing `AuditLogEntry.changes` more than once.
209+
([#2882])(https://github.com/Pycord-Development/pycord/pull/2882))
210+
- Fixed type hint for argument `start_time` and `end_time` of
211+
`Guild.create_scheduled_event`
212+
([#2879](https://github.com/Pycord-Development/pycord/pull/2879))
143213

144214
### Changed
145215

@@ -161,6 +231,8 @@ These changes are available on the `master` branch, but have not yet been releas
161231
([#2797](https://github.com/Pycord-Development/pycord/pull/2797))
162232
- Upgraded voice websocket version to v8.
163233
([#2812](https://github.com/Pycord-Development/pycord/pull/2812))
234+
- `Messageable.pins()` now returns a `MessagePinIterator` and has new arguments.
235+
([#2872](https://github.com/Pycord-Development/pycord/pull/2872))
164236

165237
### Deprecated
166238

@@ -170,6 +242,11 @@ These changes are available on the `master` branch, but have not yet been releas
170242
([#2501](https://github.com/Pycord-Development/pycord/pull/2501))
171243
- Deprecated `Interaction.cached_channel` in favor of `Interaction.channel`.
172244
([#2658](https://github.com/Pycord-Development/pycord/pull/2658))
245+
- Deprecated `is_nsfw` for categories since it was never supported by the API.
246+
([#2772](https://github.com/Pycord-Development/pycord/pull/2772))
247+
- Deprecated `Messageable.pins()` returning a list of `Message`; it should be used as an
248+
iterator of `MessagePin` instead.
249+
([#2872](https://github.com/Pycord-Development/pycord/pull/2872))
173250

174251
### Removed
175252

@@ -1079,7 +1156,9 @@ These changes are available on the `master` branch, but have not yet been releas
10791156
- Fix py3.10 UnionType checks issue.
10801157
([#1240](https://github.com/Pycord-Development/pycord/pull/1240))
10811158

1082-
[unreleased]: https://github.com/Pycord-Development/pycord/compare/v2.6.0...HEAD
1159+
[unreleased]: https://github.com/Pycord-Development/pycord/compare/v2.7.0rc1...HEAD
1160+
[2.7.0rc1]: https://github.com/Pycord-Development/pycord/compare/v2.6.0...v2.7.0rc1
1161+
[2.6.1]: https://github.com/Pycord-Development/pycord/compare/v2.6.0...v2.6.1
10831162
[2.6.0]: https://github.com/Pycord-Development/pycord/compare/v2.5.0...v2.6.0
10841163
[2.5.0]: https://github.com/Pycord-Development/pycord/compare/v2.4.1...v2.5.0
10851164
[2.4.1]: https://github.com/Pycord-Development/pycord/compare/v2.4.0...v2.4.1

README.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ Pycord is a modern, easy to use, feature-rich, and async ready API wrapper for D
2121
.. image:: https://img.shields.io/github/v/release/Pycord-Development/pycord?include_prereleases&label=Latest%20Release&logo=github&sort=semver&style=for-the-badge&logoColor=white
2222
:target: https://github.com/Pycord-Development/pycord/releases
2323
:alt: Latest release
24-
2524
.. image:: https://img.shields.io/discord/881207955029110855?label=discord&style=for-the-badge&logo=discord&color=5865F2&logoColor=white
2625
:target: https://pycord.dev/discord
2726
:alt: Discord server invite
28-
27+
.. image:: https://img.shields.io/github/sponsors/Pycord-Development?style=for-the-badge
28+
:target: https://github.com/sponsors/Pycord-Development
29+
:alt: GitHub Sponsors
2930
.. image:: https://badges.crowdin.net/badge/dark/crowdin-on-light.png
3031
:target: https://translations.pycord.dev/documentation/?utm_source=badge&utm_medium=referral&utm_campaign=badge-add-on
3132
:alt: Crowdin | Agile localization for tech companies

discord/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
from .role import *
6666
from .scheduled_events import *
6767
from .shard import *
68+
from .soundboard import *
6869
from .stage_instance import *
6970
from .sticker import *
7071
from .team import *

discord/abc.py

Lines changed: 50 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
from .file import File, VoiceMessage
4949
from .flags import ChannelFlags, MessageFlags
5050
from .invite import Invite
51-
from .iterators import HistoryIterator
51+
from .iterators import HistoryIterator, MessagePinIterator
5252
from .mentions import AllowedMentions
5353
from .partial_emoji import PartialEmoji, _EmojiTag
5454
from .permissions import PermissionOverwrite, Permissions
@@ -1679,32 +1679,64 @@ async def fetch_message(self, id: int, /) -> Message:
16791679
data = await self._state.http.get_message(channel.id, id)
16801680
return self._state.create_message(channel=channel, data=data)
16811681

1682-
async def pins(self) -> list[Message]:
1683-
"""|coro|
1682+
def pins(
1683+
self,
1684+
*,
1685+
limit: int | None = 50,
1686+
before: SnowflakeTime | None = None,
1687+
) -> MessagePinIterator:
1688+
"""Returns a :class:`~discord.MessagePinIterator` that enables receiving the destination's pinned messages.
16841689
1685-
Retrieves all messages that are currently pinned in the channel.
1690+
You must have :attr:`~discord.Permissions.read_message_history` permissions to use this.
16861691
1687-
.. note::
1692+
.. warning::
16881693
1689-
Due to a limitation with the Discord API, the :class:`.Message`
1690-
objects returned by this method do not contain complete
1691-
:attr:`.Message.reactions` data.
1694+
Starting from version 3.0, `await channel.pins()` will no longer return a list of :class:`Message`. See examples below for new usage instead.
16921695
1693-
Returns
1694-
-------
1695-
List[:class:`~discord.Message`]
1696-
The messages that are currently pinned.
1696+
Parameters
1697+
----------
1698+
limit: Optional[:class:`int`]
1699+
The number of pinned messages to retrieve.
1700+
If ``None``, retrieves every pinned message in the channel.
1701+
before: Optional[Union[:class:`~discord.abc.Snowflake`, :class:`datetime.datetime`]]
1702+
Retrieve messages pinned before this datetime.
1703+
If a datetime is provided, it is recommended to use a UTC aware datetime.
1704+
If the datetime is naive, it is assumed to be local time.
1705+
1706+
Yields
1707+
------
1708+
:class:`~discord.MessagePin`
1709+
The pinned message.
16971710
16981711
Raises
16991712
------
1713+
~discord.Forbidden
1714+
You do not have permissions to get pinned messages.
17001715
~discord.HTTPException
1701-
Retrieving the pinned messages failed.
1702-
"""
1716+
The request to get pinned messages failed.
17031717
1704-
channel = await self._get_channel()
1705-
state = self._state
1706-
data = await state.http.pins_from(channel.id)
1707-
return [state.create_message(channel=channel, data=m) for m in data]
1718+
Examples
1719+
--------
1720+
1721+
Usage ::
1722+
1723+
counter = 0
1724+
async for pin in channel.pins(limit=250):
1725+
if pin.message.author == client.user:
1726+
counter += 1
1727+
1728+
Flattening into a list: ::
1729+
1730+
pins = await channel.pins(limit=None).flatten()
1731+
# pins is now a list of MessagePin...
1732+
1733+
All parameters are optional.
1734+
"""
1735+
return MessagePinIterator(
1736+
self,
1737+
limit=limit,
1738+
before=before,
1739+
)
17081740

17091741
def can_send(self, *objects) -> bool:
17101742
"""Returns a :class:`bool` indicating whether you have the permissions to send the object(s).

discord/asset.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
if TYPE_CHECKING:
4040
ValidStaticFormatTypes = Literal["webp", "jpeg", "jpg", "png"]
4141
ValidAssetFormatTypes = Literal["webp", "jpeg", "jpg", "png", "gif"]
42+
from .state import ConnectionState
43+
4244

4345
VALID_STATIC_FORMATS = frozenset({"jpeg", "jpg", "webp", "png"})
4446
VALID_ASSET_FORMATS = VALID_STATIC_FORMATS | {"gif"}
@@ -204,6 +206,31 @@ def _from_avatar_decoration(cls, state, user_id: int, avatar_decoration: str) ->
204206
animated=animated,
205207
)
206208

209+
@classmethod
210+
def _from_user_primary_guild_tag(cls, state: ConnectionState, identity_guild_id: int, badge_id: str) -> Asset:
211+
"""Creates an Asset for a user's primary guild (tag) badge.
212+
213+
Parameters
214+
----------
215+
state: ConnectionState
216+
The connection state.
217+
identity_guild_id: int
218+
The ID of the guild.
219+
badge_id: str
220+
The badge hash/id.
221+
222+
Returns
223+
-------
224+
:class:`Asset`
225+
The primary guild badge asset.
226+
"""
227+
return cls(
228+
state,
229+
url=f"{Asset.BASE}/guild-tag-badges/{identity_guild_id}/{badge_id}.png?size=256",
230+
key=badge_id,
231+
animated=False,
232+
)
233+
207234
@classmethod
208235
def _from_guild_avatar(cls, state, guild_id: int, member_id: int, avatar: str) -> Asset:
209236
animated = avatar.startswith("a_")
@@ -244,6 +271,16 @@ def _from_cover_image(cls, state, object_id: int, cover_image_hash: str) -> Asse
244271
animated=False,
245272
)
246273

274+
@classmethod
275+
def _from_collectible(cls, state: ConnectionState, asset: str, animated: bool = False) -> Asset:
276+
name = "static.png" if not animated else "asset.webm"
277+
return cls(
278+
state,
279+
url=f"{cls.BASE}/assets/collectibles/{asset}{name}",
280+
key=asset,
281+
animated=animated,
282+
)
283+
247284
@classmethod
248285
def _from_guild_image(cls, state, guild_id: int, image: str, path: str) -> Asset:
249286
animated = False
@@ -299,6 +336,14 @@ def _from_scheduled_event_image(cls, state, event_id: int, cover_hash: str) -> A
299336
animated=False,
300337
)
301338

339+
@classmethod
340+
def _from_soundboard_sound(cls, state, sound_id: int) -> Asset:
341+
return cls(
342+
state,
343+
url=f"{cls.BASE}/soundboard-sounds/{sound_id}",
344+
key=str(sound_id),
345+
)
346+
302347
def __str__(self) -> str:
303348
return self._url
304349

discord/audit_logs.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
from __future__ import annotations
2727

28+
import datetime
2829
from functools import cached_property
2930
from typing import TYPE_CHECKING, Any, Callable, ClassVar, Generator, TypeVar
3031

@@ -46,8 +47,6 @@
4647

4748

4849
if TYPE_CHECKING:
49-
import datetime
50-
5150
from . import abc
5251
from .emoji import GuildEmoji
5352
from .guild import Guild
@@ -197,6 +196,12 @@ def _transform_trigger_metadata(
197196
return AutoModTriggerMetadata.from_dict(data)
198197

199198

199+
def _transform_communication_disabled_until(entry: AuditLogEntry, data: str) -> datetime.datetime | None:
200+
if data:
201+
return datetime.datetime.fromisoformat(data)
202+
return None
203+
204+
200205
class AuditLogDiff:
201206
def __len__(self) -> int:
202207
return len(self.__dict__)
@@ -269,6 +274,7 @@ class AuditLogChanges:
269274
"trigger_metadata": (None, _transform_trigger_metadata),
270275
"exempt_roles": (None, _transform_roles),
271276
"exempt_channels": (None, _transform_channels),
277+
"communication_disabled_until": (None, _transform_communication_disabled_until),
272278
}
273279

274280
def __init__(

0 commit comments

Comments
 (0)