Skip to content

Commit e3752ed

Browse files
authored
Merge branch 'master' into appinf
2 parents c90e24e + 15d4bca commit e3752ed

26 files changed

Lines changed: 383 additions & 127 deletions

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
- id: end-of-file-fixer
1212
exclude: \.(po|pot|yml|yaml)$
1313
- repo: https://github.com/PyCQA/autoflake
14-
rev: v2.3.1
14+
rev: v2.3.2
1515
hooks:
1616
- id: autoflake
1717
# args:

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,39 @@ These changes are available on the `master` branch, but have not yet been releas
1414

1515
- Added `Member.colours` and `Member.colors` properties.
1616
([#3063](https://github.com/Pycord-Development/pycord/pull/3063))
17+
- Added the ability to respond to interactions with suppressed push and desktop
18+
notifications. ([#3062](https://github.com/Pycord-Development/pycord/pull/3062))
19+
- Added `User.collectibles` property.
20+
([#3107](https://github.com/Pycord-Development/pycord/pull/3107))
21+
- Added the ability to compare instances of `Nameplate`.
22+
([#3107](https://github.com/Pycord-Development/pycord/pull/3107))
23+
- Added `Member.display_avatar_decoration` and `Member.guild_avatar_decoration`.
24+
([#3109](https://github.com/Pycord-Development/pycord/pull/3109))
1725

1826
### Changed
1927

2028
- Changed `Member.colour` and `Member.color` to be aliases for `Member.colours.primary`.
2129
([#3063](https://github.com/Pycord-Development/pycord/pull/3063))
30+
- Changed `User.nameplate` to be an alias for `User.collectibles.nameplate`.
31+
([#3107](https://github.com/Pycord-Development/pycord/pull/3107))
32+
- Changed `FileComponent.name` and `FileComponent.size` to be optional.
33+
([#3115](https://github.com/Pycord-Development/pycord/pull/3115))
2234

2335
### Fixed
2436

2537
- Fixed some `Item` attributes not being set correctly.
2638
([#3102](https://github.com/Pycord-Development/pycord/pull/3102))
39+
- Fixed use of deprecated `float` type for `timeout=...` in `ws_connect()`.
40+
([#3105](https://github.com/Pycord-Development/pycord/pull/3105))
41+
- Fixed the update of a user's `avatar_decoration` to now cause an `on_user_update`
42+
event to fire. ([#3103](https://github.com/Pycord-Development/pycord/pull/3103))
2743

2844
### Deprecated
2945

46+
- Deprecated the `suppress` parameter in all applicable message-related methods in favor
47+
of `suppress_embeds`.
48+
([#3062](https://github.com/Pycord-Development/pycord/pull/3062))
49+
3050
### Removed
3151

3252
- Removed the guild creation and ownership-related methods and arguments due to updated
@@ -42,9 +62,14 @@ These changes are available on the `master` branch, but have not yet been releas
4262
([#3055](https://github.com/Pycord-Development/pycord/pull/3055))
4363
- Added the ability to compare instances of `PrimaryGuild`.
4464
([#3077](https://github.com/Pycord-Development/pycord/pull/3077))
65+
- Added `cache_default_sounds` parameter to `Client` and its subclasses.
66+
([#3113](https://github.com/Pycord-Development/pycord/pull/3113))
4567

4668
### Changed
4769

70+
- Migrated away from `utils.deprecated` in favor of `warnings.deprecated`. Added type
71+
checker warnings support for function deprecations.
72+
([#3042](https://github.com/Pycord-Development/pycord/pull/3042))
4873
- Updated `Role.is_assignable()` to also check whether the bot has the `MANAGE_ROLES`
4974
permission. ([#3048](https://github.com/Pycord-Development/pycord/pull/3048))
5075
- Updated the docs' Sphinx version to v9.

discord/_version.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,12 @@
3030
import warnings
3131
from importlib.metadata import PackageNotFoundError, version
3232

33-
from typing_extensions import TypedDict
33+
from typing_extensions import TypedDict, deprecated
3434

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

3737
from typing import Literal, NamedTuple
3838

39-
from .utils import deprecated
40-
4139
try:
4240
__version__ = version("py-cord")
4341
except PackageNotFoundError:
@@ -84,27 +82,37 @@ def advanced(self, value: object) -> None:
8482
_advanced = value
8583

8684
@property
87-
@deprecated("releaselevel", "2.4")
85+
@deprecated(
86+
"VersionInfo.release_level is deprecated since version 2.4, consider using releaselevel instead."
87+
)
8888
def release_level(self) -> Literal["alpha", "beta", "candidate", "final"]:
8989
return self.releaselevel
9090

9191
@property
92-
@deprecated('.advanced["serial"]', "2.4")
92+
@deprecated(
93+
'VersionInfo.serial is deprecated since version 2.4, consider using .advanced["serial"] instead.'
94+
)
9395
def serial(self) -> int:
9496
return self.advanced["serial"]
9597

9698
@property
97-
@deprecated('.advanced["build"]', "2.4")
99+
@deprecated(
100+
'VersionInfo.build is deprecated since version 2.4, consider using .advanced["build"] instead.'
101+
)
98102
def build(self) -> int | None:
99103
return self.advanced["build"]
100104

101105
@property
102-
@deprecated('.advanced["commit"]', "2.4")
106+
@deprecated(
107+
'VersionInfo.commit is deprecated since version 2.4, consider using .advanced["commit"] instead.'
108+
)
103109
def commit(self) -> str | None:
104110
return self.advanced["commit"]
105111

106112
@property
107-
@deprecated('.advanced["date"]', "2.4")
113+
@deprecated(
114+
'VersionInfo.date is deprecated since version 2.4, consider using .advanced["date"] instead.'
115+
)
108116
def date(self) -> datetime.date | None:
109117
return self.advanced["date"]
110118

discord/abc.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
from .role import Role
5656
from .scheduled_events import ScheduledEvent
5757
from .sticker import GuildSticker, StickerItem
58+
from .utils import warn_deprecated
5859
from .voice_client import VoiceClient, VoiceProtocol
5960

6061
__all__ = (
@@ -1358,6 +1359,7 @@ async def send(
13581359
view: BaseView = ...,
13591360
poll: Poll = ...,
13601361
suppress: bool = ...,
1362+
suppress_embeds: bool = ...,
13611363
silent: bool = ...,
13621364
) -> Message: ...
13631365

@@ -1379,6 +1381,7 @@ async def send(
13791381
view: BaseView = ...,
13801382
poll: Poll = ...,
13811383
suppress: bool = ...,
1384+
suppress_embeds: bool = ...,
13821385
silent: bool = ...,
13831386
) -> Message: ...
13841387

@@ -1400,6 +1403,7 @@ async def send(
14001403
view: BaseView = ...,
14011404
poll: Poll = ...,
14021405
suppress: bool = ...,
1406+
suppress_embeds: bool = ...,
14031407
silent: bool = ...,
14041408
) -> Message: ...
14051409

@@ -1421,6 +1425,7 @@ async def send(
14211425
view: BaseView = ...,
14221426
poll: Poll = ...,
14231427
suppress: bool = ...,
1428+
suppress_embeds: bool = ...,
14241429
silent: bool = ...,
14251430
) -> Message: ...
14261431

@@ -1443,6 +1448,7 @@ async def send(
14431448
view=None,
14441449
poll=None,
14451450
suppress=None,
1451+
suppress_embeds=None,
14461452
silent=None,
14471453
):
14481454
"""|coro|
@@ -1521,6 +1527,12 @@ async def send(
15211527
.. versionadded:: 2.0
15221528
suppress: :class:`bool`
15231529
Whether to suppress embeds for the message.
1530+
1531+
.. deprecated:: 2.8
1532+
suppress_embeds: :class:`bool`
1533+
Whether to suppress embeds for the message.
1534+
1535+
.. versionadded:: 2.8
15241536
silent: :class:`bool`
15251537
Whether to suppress push and desktop notifications for the message.
15261538
@@ -1568,8 +1580,13 @@ async def send(
15681580
)
15691581
embeds = [embed.to_dict() for embed in embeds]
15701582

1583+
if suppress is not None:
1584+
warn_deprecated("suppress", "suppress_embeds", "2.8")
1585+
if suppress_embeds is None:
1586+
suppress_embeds = suppress
1587+
15711588
flags = MessageFlags(
1572-
suppress_embeds=bool(suppress),
1589+
suppress_embeds=bool(suppress_embeds),
15731590
suppress_notifications=bool(silent),
15741591
)
15751592

discord/channel.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
overload,
3939
)
4040

41+
from typing_extensions import deprecated
42+
4143
import discord.abc
4244

4345
from . import utils
@@ -3118,21 +3120,17 @@ async def create_forum_channel(self, name: str, **options: Any) -> ForumChannel:
31183120
"""
31193121
return await self.guild.create_forum_channel(name, category=self, **options)
31203122

3121-
@utils.deprecated(
3122-
since="2.7",
3123-
removed="3.0",
3124-
reference="NSFW categories are not available in the Discord API.",
3123+
@deprecated(
3124+
"CategoryChannel.is_nsfw is deprecated since version 2.7 and will be removed in version 3.0. NSFW categories are not available in the Discord API."
31253125
)
31263126
def is_nsfw(self) -> bool:
31273127
return False
31283128

31293129
# TODO: Remove in 3.0
31303130

31313131
@property
3132-
@utils.deprecated(
3133-
since="2.7",
3134-
removed="3.0",
3135-
reference="NSFW categories are not available in the Discord API.",
3132+
@deprecated(
3133+
"CategoryChannel.nsfw is deprecated since version 2.7 and will be removed in version 3.0. NSFW categories are not available in the Discord API."
31363134
)
31373135
def nsfw(self) -> bool:
31383136
return False

discord/client.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
)
4343

4444
import aiohttp
45+
from typing_extensions import deprecated
4546

4647
from . import utils
4748
from .activity import ActivityTypes, BaseActivity, create_activity
@@ -224,6 +225,10 @@ class Client:
224225
run :func:`fetch_emojis`.
225226
226227
.. versionadded:: 2.7
228+
cache_default_sounds: :class:`bool`
229+
Whether to automatically fetch and cache the default soundboard sounds on startup. Defaults to ``True``.
230+
231+
.. versionadded:: 2.8
227232
228233
Attributes
229234
-----------
@@ -1176,10 +1181,8 @@ def get_all_members(self) -> Generator[Member]:
11761181
for guild in self.guilds:
11771182
yield from guild.members
11781183

1179-
@utils.deprecated(
1180-
instead="Client.get_or_fetch(User, id)",
1181-
since="2.7",
1182-
removed="3.0",
1184+
@deprecated(
1185+
"Client.get_or_fetch_user is deprecated since version 2.7 and will be removed in version 3.0, consider using Client.get_or_fetch(User, id) instead."
11831186
)
11841187
async def get_or_fetch_user(self, id: int, /) -> User | None: # TODO: Remove in 3.0
11851188
"""|coro|

discord/collectibles.py

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,72 @@
2525
from functools import cached_property
2626
from typing import TYPE_CHECKING
2727

28+
from .asset import Asset
29+
from .types.collectibles import Collectibles as CollectiblesPayload
30+
from .types.collectibles import Nameplate as NameplatePayload
31+
2832
if TYPE_CHECKING:
2933
from .state import ConnectionState
3034

31-
from .asset import Asset
32-
from .types.collectibles import Nameplate as NameplatePayload
35+
__all__ = (
36+
"Collectibles",
37+
"Nameplate",
38+
)
39+
40+
41+
class Collectibles:
42+
"""
43+
Represents a user or member's equipped collectibles.
44+
45+
.. versionadded:: 2.8
46+
47+
.. container:: operations
48+
49+
.. describe:: x == y
50+
51+
Checks if two sets of collectibles are equal.
52+
53+
.. describe:: x != y
54+
55+
Checks if two sets of collectibles are not equal.
56+
57+
Attributes
58+
----------
59+
nameplate: :class:`Nameplate`
60+
The user's nameplate.
61+
"""
62+
63+
def __init__(self, data: CollectiblesPayload, state: "ConnectionState") -> None:
64+
if nameplate_data := data.get("nameplate"):
65+
self.nameplate = Nameplate(data=nameplate_data, state=state)
66+
else:
67+
self.nameplate = None
68+
self._state = state
69+
70+
def __repr__(self) -> str:
71+
return f"<Collectibles nameplate={self.nameplate}>"
72+
73+
def __eq__(self, other: object) -> bool:
74+
return isinstance(other, Collectibles) and self.nameplate == other.nameplate
3375

3476

3577
class Nameplate:
3678
"""
3779
Represents a Discord Nameplate.
3880
3981
.. versionadded:: 2.7
82+
.. versionchanged:: 2.8
83+
Nameplates are now comparable.
84+
85+
.. container:: operations
86+
87+
.. describe:: x == y
88+
89+
Checks if two nameplates are equal.
90+
91+
.. describe:: x != y
92+
93+
Checks if two nameplates are not equal.
4094
4195
Attributes
4296
----------
@@ -56,6 +110,13 @@ def __init__(self, data: NameplatePayload, state: "ConnectionState") -> None:
56110
def __repr__(self) -> str:
57111
return f"<Nameplate sku_id={self.sku_id} palette={self.palette}>"
58112

113+
def __eq__(self, other: object) -> bool:
114+
return (
115+
isinstance(other, Nameplate)
116+
and self.sku_id == other.sku_id
117+
and self.palette == other.palette
118+
)
119+
59120
@cached_property
60121
def static_asset(self) -> Asset:
61122
"""
@@ -73,6 +134,3 @@ def animated_asset(self) -> Asset:
73134
.. versionadded:: 2.7
74135
"""
75136
return Asset._from_collectible(self._state, self._asset, animated=True)
76-
77-
78-
__all__ = ("Nameplate",)

discord/commands/context.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ async def respond(
294294
files: list[File] | None = None,
295295
poll: Poll | None = None,
296296
delete_after: float | None = None,
297+
silent: bool = False,
298+
suppress_embeds: bool = False,
297299
) -> Interaction | WebhookMessage: ...
298300

299301
@overload
@@ -309,6 +311,8 @@ async def respond(
309311
files: list[File] | None = None,
310312
poll: Poll | None = None,
311313
delete_after: float | None = None,
314+
silent: bool = False,
315+
suppress_embeds: bool = False,
312316
) -> Interaction | WebhookMessage: ...
313317

314318
@discord.utils.copy_doc(Interaction.respond)

0 commit comments

Comments
 (0)