Skip to content

Commit

Permalink
Merge branch 'Pycord-Development:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
plun1331 authored Feb 1, 2024
2 parents bd566be + 741851b commit 336e0ac
Show file tree
Hide file tree
Showing 27 changed files with 1,567 additions and 66 deletions.
108 changes: 63 additions & 45 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@ These changes are available on the `master` branch, but have not yet been releas

### Added

- Added possibility to start bot via async context manager.
- Added method to start bot via async context manager.
([#1801](https://github.com/Pycord-Development/pycord/pull/1801))
- Added new parameters (`author`, `footer`, `image`, `thumbnail`) to `discord.Embed`.
([#1996](https://github.com/Pycord-Development/pycord/pull/1996))
- Added new events `on_bridge_command`, `on_bridge_command_completion`, and
- Added parameters `author`, `footer`, `image` and `thumbnail` to `discord.Embed`
initializer. ([#1996](https://github.com/Pycord-Development/pycord/pull/1996))
- Added events `on_bridge_command`, `on_bridge_command_completion`, and
`on_bridge_command_error`.
([#1916](https://github.com/Pycord-Development/pycord/pull/1916))
- Added the `@client.once()` decorator, which serves as a one-time event listener.
([#1940](https://github.com/Pycord-Development/pycord/pull/1940))
- Added support for text-related features in `StageChannel`.
([#1936](https://github.com/Pycord-Development/pycord/pull/1936))
- Added support for one-time event listeners in `@client.listen()`.
- Added support for one-time event listeners in `Client.listen`.
([#1957](https://github.com/Pycord-Development/pycord/pull/1957))
- Added `current_page` argument to `Paginator.update()`.
([#1983](https://github.com/Pycord-Development/pycord/pull/1983))
- Added new `application_auto_moderation_rule_create_badge` to `ApplicationFlags`.
- Added application flag `application_auto_moderation_rule_create_badge`.
([#1992](https://github.com/Pycord-Development/pycord/pull/1992))
- Added `sync_start` argument to `VoiceClient.start_recording()`. This adds silence to
the start of audio recordings.
- Added support for recording silence via new `sync_start` argument in
`VoiceClient.start_recording()`.
([#1984](https://github.com/Pycord-Development/pycord/pull/1984))
- Added `custom_message` to AutoModActionMetadata.
([#2029](https://github.com/Pycord-Development/pycord/pull/2029))
- Added support for
[voice messages](https://github.com/discord/discord-api-docs/pull/6082).
([#2016](https://github.com/Pycord-Development/pycord/pull/2016))
- Added the `data` attribute to all
- Added `data` attribute to all
[Raw Event payloads](https://docs.pycord.dev/en/master/api/models.html#events).
([#2023](https://github.com/Pycord-Development/pycord/pull/2023))
- Added and documented missing `AuditLogAction` enums.
Expand All @@ -50,21 +50,20 @@ These changes are available on the `master` branch, but have not yet been releas
- Added `view.parent` which is set when the view is sent by
`interaction.response.send_message`.
([#2036](https://github.com/Pycord-Development/pycord/pull/2036))
- Added functions (`bridge.Bot.walk_bridge_commands` &
`BridgeCommandGroup.walk_commands`) to cycle through all bridge commands and their
children/subcommands.
- Added methods `bridge.Bot.walk_bridge_commands` and
`BridgeCommandGroup.walk_commands`.
([#1867](https://github.com/Pycord-Development/pycord/pull/1867))
- Added support for usernames and modified multiple methods accordingly.
([#2042](https://github.com/Pycord-Development/pycord/pull/2042))
- Added `icon` and `unicode_emoji` to `Guild.create_role`.
- Added `icon` and `unicode_emoji` arguments to `Guild.create_role`.
([#2086](https://github.com/Pycord-Development/pycord/pull/2086))
- Added `cooldown` and `max_concurrency` to `SlashCommandGroup`.
- Added `cooldown` and `max_concurrency` attributes to `SlashCommandGroup`.
([#2091](https://github.com/Pycord-Development/pycord/pull/2091))
- Added new embedded activities, Gartic Phone and Jamspace.
- Added embedded activities Gartic Phone and Jamspace.
([#2102](https://github.com/Pycord-Development/pycord/pull/2102))
- Added `bridge.Context` as a shortcut to `Union` of subclasses.
- Added `bridge.Context` type as a `Union` of subclasses.
([#2106](https://github.com/Pycord-Development/pycord/pull/2106))
- Added Annotated forms support for type-hinting slash command options.
- Added support for type-hinting slash command options with `typing.Annotated`.
([#2124](https://github.com/Pycord-Development/pycord/pull/2124))
- Added `suppress` and `allowed_mentions` parameters to `Webhook` and
`InteractionResponse` edit methods.
Expand All @@ -79,18 +78,26 @@ These changes are available on the `master` branch, but have not yet been releas
([#2112](https://github.com/Pycord-Development/pycord/pull/2112))
- Added `ForumChannel.default_reaction_emoji` attribute.
([#2178](https://github.com/Pycord-Development/pycord/pull/2178))
- Added `default_reaction_emoji` parameter to `Guild.create_forum_channel()` and
`ForumChannel.edit()` methods.
- Added `default_reaction_emoji` parameter to `Guild.create_forum_channel` and
`ForumChannel.edit` methods.
([#2178](https://github.com/Pycord-Development/pycord/pull/2178))
- Added `applied_tags` parameter to `Webhook.send()` method.
- Added `applied_tags` parameter to `Webhook.send` method.
([#2322](https://github.com/Pycord-Development/pycord/pull/2322))
- Added `User.avatar_decoration`.
([#2131](https://github.com/Pycord-Development/pycord/pull/2131))
- Added support for guild onboarding related features.
([#2127](https://github.com/Pycord-Development/pycord/pull/2127))
- Added support for monetization related objects and events.
([#2273](https://github.com/Pycord-Development/pycord/pull/2273))
- Added `AttachmentFlags` and attachment attributes `expires_at`, `issued_at` and `hm`.
([#2342](https://github.com/Pycord-Development/pycord/pull/2342))

### Changed

- Changed default for all `name_localizations` & `description_localizations` attributes
from being `None` to being `MISSING`.
- Changed default for all `name_localizations` and `description_localizations`
attributes from being `None` to being `MISSING`.
([#1866](https://github.com/Pycord-Development/pycord/pull/1866))
- Changed FFMPEG output suppression when recording voice channels.
- Changed `ffmpeg` output suppression when recording voice channels.
([#1993](https://github.com/Pycord-Development/pycord/pull/1993))
- Changed file-upload size limit from 8 MB to 25 MB accordingly.
([#2014](https://github.com/Pycord-Development/pycord/pull/2014))
Expand All @@ -101,30 +108,29 @@ These changes are available on the `master` branch, but have not yet been releas
([#2025](https://github.com/Pycord-Development/pycord/pull/2025))
- Changed `DMChannel.recipients` to potentially be `None`.
([#2025](https://github.com/Pycord-Development/pycord/pull/2025))
- Changed the behavior to store `view.message` when receiving an Interaction for a
component. ([#2036](https://github.com/Pycord-Development/pycord/pull/2036))
- Changed the behavior to store `view.message` when receiving a component interaction,
while also changing `view.message` not to be set when sending view through
`InteractionResponse.send_message`.
([#2036](https://github.com/Pycord-Development/pycord/pull/2036))
- Changed the fetching of attributes shared between text-based and Slash Commands in
Bridge Commands to be dynamic.
([#1867](https://github.com/Pycord-Development/pycord/pull/1867))
- Changed `discord.Embed` attributes (such as author, footer, etc.) now return `None`
when not set, and return their respective classes when set.
- `discord.Embed` attributes (such as author, footer, etc.) now return instances of
their respective classes when set and `None` otherwise.
([#2063](https://github.com/Pycord-Development/pycord/pull/2063))
- Changed `default_avatar` behavior depending on the user's username migration status.
- Changed `default_avatar` behavior to depend on the user's username migration status.
([#2087](https://github.com/Pycord-Development/pycord/pull/2087))
- Changed type-hinted `command_prefix` and `help_command` arguments properly.
- Changed type hints of `command_prefix` and `help_command` arguments to be accurate.
([#2099](https://github.com/Pycord-Development/pycord/pull/2099))
- Changed the support from `orjson` to `msgspec` in the codebase.
- Replaced `orjson` features with `msgspec` in the codebase.
([#2170](https://github.com/Pycord-Development/pycord/pull/2170))
- `BridgeOption` must now be used for arguments in bridge commands.
([#2252](https://github.com/Pycord-Development/pycord/pull/2252))

### Removed

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

Expand All @@ -133,8 +139,8 @@ These changes are available on the `master` branch, but have not yet been releas
- Fixed `AttributeError` caused by
[#1957](https://github.com/Pycord-Development/pycord/pull/1957) when using listeners
in cogs. ([#1989](https://github.com/Pycord-Development/pycord/pull/1989))
- Editing a webhook message if the thread is a forum post or if the thread is a private
thread ([#1981](https://github.com/Pycord-Development/pycord/pull/1981))
- Fixed an issue in editing webhook messages in forum posts and private threads.
([#1981](https://github.com/Pycord-Development/pycord/pull/1981)).
- Fixed `View.message` not being set when view is sent using webhooks, including
`Interaction.followup.send` or when a message is edited.
([#1997](https://github.com/Pycord-Development/pycord/pull/1997))
Expand All @@ -144,7 +150,7 @@ These changes are available on the `master` branch, but have not yet been releas
([#1998](https://github.com/Pycord-Development/pycord/pull/1998))
- Fixed boolean converter breaking for Bridge Commands.
([#1999](https://github.com/Pycord-Development/pycord/pull/1999))
- Fixed Bridge Command Options not working.
- Fixed bridge command options not working.
([#1999](https://github.com/Pycord-Development/pycord/pull/1999))
- Fixed `TypeError` being raised when passing `name` argument to bridge groups.
([#2000](https://github.com/Pycord-Development/pycord/pull/2000))
Expand All @@ -153,9 +159,9 @@ These changes are available on the `master` branch, but have not yet been releas
- Fixed the functionality to override the default `on_application_command_error`
behavior using listeners.
([#2044](https://github.com/Pycord-Development/pycord/pull/2044))
- Fixed unloading of cogs having Bridge Commands.
- Fixed unloading of cogs with bridge commands.
([#2048](https://github.com/Pycord-Development/pycord/pull/2048))
- Fixed the Slash Command synchronization method `individual`.
- Fixed the `individual` slash command synchronization method.
([#1925](https://github.com/Pycord-Development/pycord/pull/1925))
- Fixed an issue that occurred when `webhooks_update` event payload channel ID was
`None`. ([#2078](https://github.com/Pycord-Development/pycord/pull/2078))
Expand All @@ -173,7 +179,7 @@ These changes are available on the `master` branch, but have not yet been releas
([#2145](https://github.com/Pycord-Development/pycord/pull/2145))
- Fixed `Thread.applied_tags` not being updated.
([#2146](https://github.com/Pycord-Development/pycord/pull/2146))
- Fixed type-hinting of `author` property of `ApplicationContext` to include
- Fixed type hinting of `author` property of `ApplicationContext` to include
type-hinting of `User` or `Member`.
([#2148](https://github.com/Pycord-Development/pycord/pull/2148))
- Fixed missing `delete_after` parameter in overload type-hinting for `Webhook.send()`.
Expand All @@ -182,16 +188,16 @@ These changes are available on the `master` branch, but have not yet been releas
([#2162](https://github.com/Pycord-Development/pycord/pull/2162))
- Fixed `_bytes_to_base64_data` not defined.
([#2185](https://github.com/Pycord-Development/pycord/pull/2185))
- Fixed type-hinting of `values` argument of `basic_autocomplete` to include
type-hinting of `Iterable[OptionChoice]`.
- Fixed inaccurate `Union` type hint of `values` argument of `basic_autocomplete` to
include `Iterable[OptionChoice]`.
([#2164](https://github.com/Pycord-Development/pycord/pull/2164))
- Fixed initial message inside of the create thread payload sending legacy beta payload.
([#2191](https://github.com/Pycord-Development/pycord/pull/2191))
- Fixed a misplaced payload object inside of the thread creation payload.
([#2192](https://github.com/Pycord-Development/pycord/pull/2192))
- Fixed `DMChannel.recipient` being `None` and consequently `User.dm_channel` also being
`None`. ([#2219](https://github.com/Pycord-Development/pycord/pull/2219))
- Fixed ffmpeg being terminated prematurely when piping audio stream.
- Fixed `DMChannel.recipient` and `User.dm_channel` being `None`.
([#2219](https://github.com/Pycord-Development/pycord/pull/2219))
- Fixed `ffmpeg` being terminated prematurely when piping audio stream.
([#2240](https://github.com/Pycord-Development/pycord/pull/2240))
- Fixed tasks looping infinitely when `tzinfo` is neither `None` nor UTC.
([#2196](https://github.com/Pycord-Development/pycord/pull/2196))
Expand All @@ -217,6 +223,18 @@ These changes are available on the `master` branch, but have not yet been releas
([#2299](https://github.com/Pycord-Development/pycord/issues/2299))
- Fixed `AttributeError` when copying groups on startup.
([#2331](https://github.com/Pycord-Development/pycord/issues/2331))
- Fixed application command options causing errors if declared through the option
decorator or kwarg.
([#2332](https://github.com/Pycord-Development/pycord/issues/2332))
- Fixed options declared using the parameter default value syntax always being optional.
([#2333](https://github.com/Pycord-Development/pycord/issues/2333))
- Fixed `BridgeContext` type hints raising an exception for unsupported option type.
([#2337](https://github.com/Pycord-Development/pycord/pull/2337))
- Fixed `TypeError` due to `(Sync)WebhookMessage._thread_id` being set to `None`.
([#2343](https://github.com/Pycord-Development/pycord/pull/2343))
- Fixed `AttributeError` due to `entitlements` not being included in
`Interaction.__slots__`.
([#2345](https://github.com/Pycord-Development/pycord/pull/2345))

## [2.4.1] - 2023-03-20

Expand Down
2 changes: 2 additions & 0 deletions discord/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
from .member import *
from .mentions import *
from .message import *
from .monetization import *
from .object import *
from .onboarding import *
from .partial_emoji import *
from .permissions import *
from .player import *
Expand Down
17 changes: 17 additions & 0 deletions discord/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,23 @@ def _from_avatar(cls, state, user_id: int, avatar: str) -> Asset:
animated=animated,
)

@classmethod
def _from_avatar_decoration(
cls, state, user_id: int, avatar_decoration: str
) -> Asset:
animated = avatar_decoration.startswith("a_")
endpoint = (
"avatar-decoration-presets"
# if avatar_decoration.startswith(("v3", "v2"))
# else f"avatar-decorations/{user_id}"
)
return cls(
state,
url=f"{cls.BASE}/{endpoint}/{avatar_decoration}.png?size=1024",
key=avatar_decoration,
animated=animated,
)

@classmethod
def _from_guild_avatar(
cls, state, guild_id: int, member_id: int, avatar: str
Expand Down
31 changes: 31 additions & 0 deletions discord/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from .invite import Invite
from .iterators import GuildIterator
from .mentions import AllowedMentions
from .monetization import SKU, Entitlement
from .object import Object
from .stage_instance import StageInstance
from .state import ConnectionState
Expand Down Expand Up @@ -2002,3 +2003,33 @@ async def update_role_connection_metadata_records(
self.application_id, payload
)
return [ApplicationRoleConnectionMetadata.from_dict(r) for r in data]

async def fetch_skus(self) -> list[SKU]:
"""|coro|
Fetches the bot's SKUs.
.. versionadded:: 2.5
Returns
-------
List[:class:`.SKU`]
The bot's SKUs.
"""
data = await self._connection.http.list_skus(self.application_id)
return [SKU(data=s) for s in data]

async def fetch_entitlements(self) -> list[Entitlement]:
"""|coro|
Fetches the bot's entitlements.
.. versionadded:: 2.5
Returns
-------
List[:class:`.Entitlement`]
The bot's entitlements.
"""
data = await self._connection.http.list_entitlements(self.application_id)
return [Entitlement(data=e, state=self._connection) for e in data]
16 changes: 7 additions & 9 deletions discord/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,23 +760,21 @@ def _parse_options(self, params, *, check_params: bool = True) -> list[Option]:

if not isinstance(option, Option):
if isinstance(p_obj.default, Option):
p_obj.default.input_type = SlashCommandOptionType.from_datatype(
option
)
if p_obj.default.input_type is None:
p_obj.default.input_type = SlashCommandOptionType.from_datatype(
option
)
option = p_obj.default
else:
option = Option(option)

if option.default is None and not p_obj.default == inspect.Parameter.empty:
if isinstance(p_obj.default, type) and issubclass(
if isinstance(p_obj.default, Option):
pass
elif isinstance(p_obj.default, type) and issubclass(
p_obj.default, (DiscordEnum, Enum)
):
option = Option(p_obj.default)
elif (
isinstance(p_obj.default, Option)
and not (default := p_obj.default.default) is None
):
option.default = default
else:
option.default = p_obj.default
option.required = False
Expand Down
Loading

0 comments on commit 336e0ac

Please sign in to comment.