Skip to content

Commit 336e0ac

Browse files
authored
Merge branch 'Pycord-Development:master' into master
2 parents bd566be + 741851b commit 336e0ac

27 files changed

+1567
-66
lines changed

CHANGELOG.md

Lines changed: 63 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,32 @@ These changes are available on the `master` branch, but have not yet been releas
1212

1313
### Added
1414

15-
- Added possibility to start bot via async context manager.
15+
- Added method to start bot via async context manager.
1616
([#1801](https://github.com/Pycord-Development/pycord/pull/1801))
17-
- Added new parameters (`author`, `footer`, `image`, `thumbnail`) to `discord.Embed`.
18-
([#1996](https://github.com/Pycord-Development/pycord/pull/1996))
19-
- Added new events `on_bridge_command`, `on_bridge_command_completion`, and
17+
- Added parameters `author`, `footer`, `image` and `thumbnail` to `discord.Embed`
18+
initializer. ([#1996](https://github.com/Pycord-Development/pycord/pull/1996))
19+
- Added events `on_bridge_command`, `on_bridge_command_completion`, and
2020
`on_bridge_command_error`.
2121
([#1916](https://github.com/Pycord-Development/pycord/pull/1916))
2222
- Added the `@client.once()` decorator, which serves as a one-time event listener.
2323
([#1940](https://github.com/Pycord-Development/pycord/pull/1940))
2424
- Added support for text-related features in `StageChannel`.
2525
([#1936](https://github.com/Pycord-Development/pycord/pull/1936))
26-
- Added support for one-time event listeners in `@client.listen()`.
26+
- Added support for one-time event listeners in `Client.listen`.
2727
([#1957](https://github.com/Pycord-Development/pycord/pull/1957))
2828
- Added `current_page` argument to `Paginator.update()`.
2929
([#1983](https://github.com/Pycord-Development/pycord/pull/1983))
30-
- Added new `application_auto_moderation_rule_create_badge` to `ApplicationFlags`.
30+
- Added application flag `application_auto_moderation_rule_create_badge`.
3131
([#1992](https://github.com/Pycord-Development/pycord/pull/1992))
32-
- Added `sync_start` argument to `VoiceClient.start_recording()`. This adds silence to
33-
the start of audio recordings.
32+
- Added support for recording silence via new `sync_start` argument in
33+
`VoiceClient.start_recording()`.
3434
([#1984](https://github.com/Pycord-Development/pycord/pull/1984))
3535
- Added `custom_message` to AutoModActionMetadata.
3636
([#2029](https://github.com/Pycord-Development/pycord/pull/2029))
3737
- Added support for
3838
[voice messages](https://github.com/discord/discord-api-docs/pull/6082).
3939
([#2016](https://github.com/Pycord-Development/pycord/pull/2016))
40-
- Added the `data` attribute to all
40+
- Added `data` attribute to all
4141
[Raw Event payloads](https://docs.pycord.dev/en/master/api/models.html#events).
4242
([#2023](https://github.com/Pycord-Development/pycord/pull/2023))
4343
- Added and documented missing `AuditLogAction` enums.
@@ -50,21 +50,20 @@ These changes are available on the `master` branch, but have not yet been releas
5050
- Added `view.parent` which is set when the view is sent by
5151
`interaction.response.send_message`.
5252
([#2036](https://github.com/Pycord-Development/pycord/pull/2036))
53-
- Added functions (`bridge.Bot.walk_bridge_commands` &
54-
`BridgeCommandGroup.walk_commands`) to cycle through all bridge commands and their
55-
children/subcommands.
53+
- Added methods `bridge.Bot.walk_bridge_commands` and
54+
`BridgeCommandGroup.walk_commands`.
5655
([#1867](https://github.com/Pycord-Development/pycord/pull/1867))
5756
- Added support for usernames and modified multiple methods accordingly.
5857
([#2042](https://github.com/Pycord-Development/pycord/pull/2042))
59-
- Added `icon` and `unicode_emoji` to `Guild.create_role`.
58+
- Added `icon` and `unicode_emoji` arguments to `Guild.create_role`.
6059
([#2086](https://github.com/Pycord-Development/pycord/pull/2086))
61-
- Added `cooldown` and `max_concurrency` to `SlashCommandGroup`.
60+
- Added `cooldown` and `max_concurrency` attributes to `SlashCommandGroup`.
6261
([#2091](https://github.com/Pycord-Development/pycord/pull/2091))
63-
- Added new embedded activities, Gartic Phone and Jamspace.
62+
- Added embedded activities Gartic Phone and Jamspace.
6463
([#2102](https://github.com/Pycord-Development/pycord/pull/2102))
65-
- Added `bridge.Context` as a shortcut to `Union` of subclasses.
64+
- Added `bridge.Context` type as a `Union` of subclasses.
6665
([#2106](https://github.com/Pycord-Development/pycord/pull/2106))
67-
- Added Annotated forms support for type-hinting slash command options.
66+
- Added support for type-hinting slash command options with `typing.Annotated`.
6867
([#2124](https://github.com/Pycord-Development/pycord/pull/2124))
6968
- Added `suppress` and `allowed_mentions` parameters to `Webhook` and
7069
`InteractionResponse` edit methods.
@@ -79,18 +78,26 @@ These changes are available on the `master` branch, but have not yet been releas
7978
([#2112](https://github.com/Pycord-Development/pycord/pull/2112))
8079
- Added `ForumChannel.default_reaction_emoji` attribute.
8180
([#2178](https://github.com/Pycord-Development/pycord/pull/2178))
82-
- Added `default_reaction_emoji` parameter to `Guild.create_forum_channel()` and
83-
`ForumChannel.edit()` methods.
81+
- Added `default_reaction_emoji` parameter to `Guild.create_forum_channel` and
82+
`ForumChannel.edit` methods.
8483
([#2178](https://github.com/Pycord-Development/pycord/pull/2178))
85-
- Added `applied_tags` parameter to `Webhook.send()` method.
84+
- Added `applied_tags` parameter to `Webhook.send` method.
8685
([#2322](https://github.com/Pycord-Development/pycord/pull/2322))
86+
- Added `User.avatar_decoration`.
87+
([#2131](https://github.com/Pycord-Development/pycord/pull/2131))
88+
- Added support for guild onboarding related features.
89+
([#2127](https://github.com/Pycord-Development/pycord/pull/2127))
90+
- Added support for monetization related objects and events.
91+
([#2273](https://github.com/Pycord-Development/pycord/pull/2273))
92+
- Added `AttachmentFlags` and attachment attributes `expires_at`, `issued_at` and `hm`.
93+
([#2342](https://github.com/Pycord-Development/pycord/pull/2342))
8794

8895
### Changed
8996

90-
- Changed default for all `name_localizations` & `description_localizations` attributes
91-
from being `None` to being `MISSING`.
97+
- Changed default for all `name_localizations` and `description_localizations`
98+
attributes from being `None` to being `MISSING`.
9299
([#1866](https://github.com/Pycord-Development/pycord/pull/1866))
93-
- Changed FFMPEG output suppression when recording voice channels.
100+
- Changed `ffmpeg` output suppression when recording voice channels.
94101
([#1993](https://github.com/Pycord-Development/pycord/pull/1993))
95102
- Changed file-upload size limit from 8 MB to 25 MB accordingly.
96103
([#2014](https://github.com/Pycord-Development/pycord/pull/2014))
@@ -101,30 +108,29 @@ These changes are available on the `master` branch, but have not yet been releas
101108
([#2025](https://github.com/Pycord-Development/pycord/pull/2025))
102109
- Changed `DMChannel.recipients` to potentially be `None`.
103110
([#2025](https://github.com/Pycord-Development/pycord/pull/2025))
104-
- Changed the behavior to store `view.message` when receiving an Interaction for a
105-
component. ([#2036](https://github.com/Pycord-Development/pycord/pull/2036))
111+
- Changed the behavior to store `view.message` when receiving a component interaction,
112+
while also changing `view.message` not to be set when sending view through
113+
`InteractionResponse.send_message`.
114+
([#2036](https://github.com/Pycord-Development/pycord/pull/2036))
106115
- Changed the fetching of attributes shared between text-based and Slash Commands in
107116
Bridge Commands to be dynamic.
108117
([#1867](https://github.com/Pycord-Development/pycord/pull/1867))
109-
- Changed `discord.Embed` attributes (such as author, footer, etc.) now return `None`
110-
when not set, and return their respective classes when set.
118+
- `discord.Embed` attributes (such as author, footer, etc.) now return instances of
119+
their respective classes when set and `None` otherwise.
111120
([#2063](https://github.com/Pycord-Development/pycord/pull/2063))
112-
- Changed `default_avatar` behavior depending on the user's username migration status.
121+
- Changed `default_avatar` behavior to depend on the user's username migration status.
113122
([#2087](https://github.com/Pycord-Development/pycord/pull/2087))
114-
- Changed type-hinted `command_prefix` and `help_command` arguments properly.
123+
- Changed type hints of `command_prefix` and `help_command` arguments to be accurate.
115124
([#2099](https://github.com/Pycord-Development/pycord/pull/2099))
116-
- Changed the support from `orjson` to `msgspec` in the codebase.
125+
- Replaced `orjson` features with `msgspec` in the codebase.
117126
([#2170](https://github.com/Pycord-Development/pycord/pull/2170))
118127
- `BridgeOption` must now be used for arguments in bridge commands.
119128
([#2252](https://github.com/Pycord-Development/pycord/pull/2252))
120129

121130
### Removed
122131

123-
- Removed `@client.once()` in favour of `@client.listen(once=True)`.
132+
- Removed `Client.once` in favour of `once` argument in `Client.listen`.
124133
([#1957](https://github.com/Pycord-Development/pycord/pull/1957))
125-
- Removed `view.message` being set when the view was sent by
126-
`interaction.response.send_message`.
127-
([#2036](https://github.com/Pycord-Development/pycord/pull/2036))
128134
- Removed `Embed.Empty` in favour of `None`, and `EmbedProxy` in favour of individual
129135
classes. ([#2063](https://github.com/Pycord-Development/pycord/pull/2063))
130136

@@ -133,8 +139,8 @@ These changes are available on the `master` branch, but have not yet been releas
133139
- Fixed `AttributeError` caused by
134140
[#1957](https://github.com/Pycord-Development/pycord/pull/1957) when using listeners
135141
in cogs. ([#1989](https://github.com/Pycord-Development/pycord/pull/1989))
136-
- Editing a webhook message if the thread is a forum post or if the thread is a private
137-
thread ([#1981](https://github.com/Pycord-Development/pycord/pull/1981))
142+
- Fixed an issue in editing webhook messages in forum posts and private threads.
143+
([#1981](https://github.com/Pycord-Development/pycord/pull/1981)).
138144
- Fixed `View.message` not being set when view is sent using webhooks, including
139145
`Interaction.followup.send` or when a message is edited.
140146
([#1997](https://github.com/Pycord-Development/pycord/pull/1997))
@@ -144,7 +150,7 @@ These changes are available on the `master` branch, but have not yet been releas
144150
([#1998](https://github.com/Pycord-Development/pycord/pull/1998))
145151
- Fixed boolean converter breaking for Bridge Commands.
146152
([#1999](https://github.com/Pycord-Development/pycord/pull/1999))
147-
- Fixed Bridge Command Options not working.
153+
- Fixed bridge command options not working.
148154
([#1999](https://github.com/Pycord-Development/pycord/pull/1999))
149155
- Fixed `TypeError` being raised when passing `name` argument to bridge groups.
150156
([#2000](https://github.com/Pycord-Development/pycord/pull/2000))
@@ -153,9 +159,9 @@ These changes are available on the `master` branch, but have not yet been releas
153159
- Fixed the functionality to override the default `on_application_command_error`
154160
behavior using listeners.
155161
([#2044](https://github.com/Pycord-Development/pycord/pull/2044))
156-
- Fixed unloading of cogs having Bridge Commands.
162+
- Fixed unloading of cogs with bridge commands.
157163
([#2048](https://github.com/Pycord-Development/pycord/pull/2048))
158-
- Fixed the Slash Command synchronization method `individual`.
164+
- Fixed the `individual` slash command synchronization method.
159165
([#1925](https://github.com/Pycord-Development/pycord/pull/1925))
160166
- Fixed an issue that occurred when `webhooks_update` event payload channel ID was
161167
`None`. ([#2078](https://github.com/Pycord-Development/pycord/pull/2078))
@@ -173,7 +179,7 @@ These changes are available on the `master` branch, but have not yet been releas
173179
([#2145](https://github.com/Pycord-Development/pycord/pull/2145))
174180
- Fixed `Thread.applied_tags` not being updated.
175181
([#2146](https://github.com/Pycord-Development/pycord/pull/2146))
176-
- Fixed type-hinting of `author` property of `ApplicationContext` to include
182+
- Fixed type hinting of `author` property of `ApplicationContext` to include
177183
type-hinting of `User` or `Member`.
178184
([#2148](https://github.com/Pycord-Development/pycord/pull/2148))
179185
- Fixed missing `delete_after` parameter in overload type-hinting for `Webhook.send()`.
@@ -182,16 +188,16 @@ These changes are available on the `master` branch, but have not yet been releas
182188
([#2162](https://github.com/Pycord-Development/pycord/pull/2162))
183189
- Fixed `_bytes_to_base64_data` not defined.
184190
([#2185](https://github.com/Pycord-Development/pycord/pull/2185))
185-
- Fixed type-hinting of `values` argument of `basic_autocomplete` to include
186-
type-hinting of `Iterable[OptionChoice]`.
191+
- Fixed inaccurate `Union` type hint of `values` argument of `basic_autocomplete` to
192+
include `Iterable[OptionChoice]`.
187193
([#2164](https://github.com/Pycord-Development/pycord/pull/2164))
188194
- Fixed initial message inside of the create thread payload sending legacy beta payload.
189195
([#2191](https://github.com/Pycord-Development/pycord/pull/2191))
190196
- Fixed a misplaced payload object inside of the thread creation payload.
191197
([#2192](https://github.com/Pycord-Development/pycord/pull/2192))
192-
- Fixed `DMChannel.recipient` being `None` and consequently `User.dm_channel` also being
193-
`None`. ([#2219](https://github.com/Pycord-Development/pycord/pull/2219))
194-
- Fixed ffmpeg being terminated prematurely when piping audio stream.
198+
- Fixed `DMChannel.recipient` and `User.dm_channel` being `None`.
199+
([#2219](https://github.com/Pycord-Development/pycord/pull/2219))
200+
- Fixed `ffmpeg` being terminated prematurely when piping audio stream.
195201
([#2240](https://github.com/Pycord-Development/pycord/pull/2240))
196202
- Fixed tasks looping infinitely when `tzinfo` is neither `None` nor UTC.
197203
([#2196](https://github.com/Pycord-Development/pycord/pull/2196))
@@ -217,6 +223,18 @@ These changes are available on the `master` branch, but have not yet been releas
217223
([#2299](https://github.com/Pycord-Development/pycord/issues/2299))
218224
- Fixed `AttributeError` when copying groups on startup.
219225
([#2331](https://github.com/Pycord-Development/pycord/issues/2331))
226+
- Fixed application command options causing errors if declared through the option
227+
decorator or kwarg.
228+
([#2332](https://github.com/Pycord-Development/pycord/issues/2332))
229+
- Fixed options declared using the parameter default value syntax always being optional.
230+
([#2333](https://github.com/Pycord-Development/pycord/issues/2333))
231+
- Fixed `BridgeContext` type hints raising an exception for unsupported option type.
232+
([#2337](https://github.com/Pycord-Development/pycord/pull/2337))
233+
- Fixed `TypeError` due to `(Sync)WebhookMessage._thread_id` being set to `None`.
234+
([#2343](https://github.com/Pycord-Development/pycord/pull/2343))
235+
- Fixed `AttributeError` due to `entitlements` not being included in
236+
`Interaction.__slots__`.
237+
([#2345](https://github.com/Pycord-Development/pycord/pull/2345))
220238

221239
## [2.4.1] - 2023-03-20
222240

discord/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@
5252
from .member import *
5353
from .mentions import *
5454
from .message import *
55+
from .monetization import *
5556
from .object import *
57+
from .onboarding import *
5658
from .partial_emoji import *
5759
from .permissions import *
5860
from .player import *

discord/asset.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,23 @@ def _from_avatar(cls, state, user_id: int, avatar: str) -> Asset:
182182
animated=animated,
183183
)
184184

185+
@classmethod
186+
def _from_avatar_decoration(
187+
cls, state, user_id: int, avatar_decoration: str
188+
) -> Asset:
189+
animated = avatar_decoration.startswith("a_")
190+
endpoint = (
191+
"avatar-decoration-presets"
192+
# if avatar_decoration.startswith(("v3", "v2"))
193+
# else f"avatar-decorations/{user_id}"
194+
)
195+
return cls(
196+
state,
197+
url=f"{cls.BASE}/{endpoint}/{avatar_decoration}.png?size=1024",
198+
key=avatar_decoration,
199+
animated=animated,
200+
)
201+
185202
@classmethod
186203
def _from_guild_avatar(
187204
cls, state, guild_id: int, member_id: int, avatar: str

discord/client.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
from .invite import Invite
5252
from .iterators import GuildIterator
5353
from .mentions import AllowedMentions
54+
from .monetization import SKU, Entitlement
5455
from .object import Object
5556
from .stage_instance import StageInstance
5657
from .state import ConnectionState
@@ -2002,3 +2003,33 @@ async def update_role_connection_metadata_records(
20022003
self.application_id, payload
20032004
)
20042005
return [ApplicationRoleConnectionMetadata.from_dict(r) for r in data]
2006+
2007+
async def fetch_skus(self) -> list[SKU]:
2008+
"""|coro|
2009+
2010+
Fetches the bot's SKUs.
2011+
2012+
.. versionadded:: 2.5
2013+
2014+
Returns
2015+
-------
2016+
List[:class:`.SKU`]
2017+
The bot's SKUs.
2018+
"""
2019+
data = await self._connection.http.list_skus(self.application_id)
2020+
return [SKU(data=s) for s in data]
2021+
2022+
async def fetch_entitlements(self) -> list[Entitlement]:
2023+
"""|coro|
2024+
2025+
Fetches the bot's entitlements.
2026+
2027+
.. versionadded:: 2.5
2028+
2029+
Returns
2030+
-------
2031+
List[:class:`.Entitlement`]
2032+
The bot's entitlements.
2033+
"""
2034+
data = await self._connection.http.list_entitlements(self.application_id)
2035+
return [Entitlement(data=e, state=self._connection) for e in data]

discord/commands/core.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -760,23 +760,21 @@ def _parse_options(self, params, *, check_params: bool = True) -> list[Option]:
760760

761761
if not isinstance(option, Option):
762762
if isinstance(p_obj.default, Option):
763-
p_obj.default.input_type = SlashCommandOptionType.from_datatype(
764-
option
765-
)
763+
if p_obj.default.input_type is None:
764+
p_obj.default.input_type = SlashCommandOptionType.from_datatype(
765+
option
766+
)
766767
option = p_obj.default
767768
else:
768769
option = Option(option)
769770

770771
if option.default is None and not p_obj.default == inspect.Parameter.empty:
771-
if isinstance(p_obj.default, type) and issubclass(
772+
if isinstance(p_obj.default, Option):
773+
pass
774+
elif isinstance(p_obj.default, type) and issubclass(
772775
p_obj.default, (DiscordEnum, Enum)
773776
):
774777
option = Option(p_obj.default)
775-
elif (
776-
isinstance(p_obj.default, Option)
777-
and not (default := p_obj.default.default) is None
778-
):
779-
option.default = default
780778
else:
781779
option.default = p_obj.default
782780
option.required = False

0 commit comments

Comments
 (0)