diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index d64c44f2a5..84f6a9bf34 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -9,8 +9,8 @@ jobs: codespell: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: "3.11" cache: "pip" @@ -25,8 +25,8 @@ jobs: bandit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: "3.11" cache: "pip" diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 63eb6a6ff7..4fbb2b5b8a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -41,11 +41,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3.1.0 + uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -56,7 +56,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 # ℹī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -70,4 +70,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index eebcd0b41e..44e5c35799 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,8 +9,8 @@ jobs: pylint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: "3.11" cache: "pip" @@ -31,8 +31,8 @@ jobs: mypy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: "3.11" cache: "pip" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9ad535184a..effb760e9f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,8 +21,8 @@ jobs: OS: ${{ matrix.os }} PYTHON: ${{ matrix.python-version }} steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} cache: "pip" @@ -48,9 +48,9 @@ jobs: docs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3.1.0 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.8" cache: "pip" diff --git a/.github/workflows/todo.yml b/.github/workflows/todo.yml index fec76a1f57..508f34218f 100644 --- a/.github/workflows/todo.yml +++ b/.github/workflows/todo.yml @@ -4,7 +4,7 @@ jobs: todo: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run tdg-github-action uses: ribtoks/tdg-github-action@v0.4.7-beta with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 43519b50cd..e0cd7bbdfe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,12 +4,12 @@ ci: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - repo: https://github.com/PyCQA/autoflake - rev: v2.2.0 + rev: v2.2.1 hooks: - id: autoflake # args: @@ -19,7 +19,7 @@ repos: # - --remove-duplicate-keys # - --remove-unused-variables - repo: https://github.com/asottile/pyupgrade - rev: v3.9.0 + rev: v3.15.0 hooks: - id: pyupgrade args: [--py38-plus] @@ -28,7 +28,7 @@ repos: hooks: - id: isort - repo: https://github.com/psf/black - rev: 23.7.0 + rev: 23.11.0 hooks: - id: black args: [--safe, --quiet] @@ -77,7 +77,7 @@ repos: # - id: mypy - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.0 + rev: v3.1.0 hooks: - id: prettier args: [--prose-wrap=always, --print-width=88] diff --git a/CHANGELOG.md b/CHANGELOG.md index 85026439b0..6928a6bac4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,9 +14,6 @@ These changes are available on the `master` branch, but have not yet been releas - Added possibility to start bot via async context manager. ([#1801](https://github.com/Pycord-Development/pycord/pull/1801)) -- Change default for all `name_localizations` & `description_localizations` attributes - from being `None` to be `MISSING`. - ([#1866](https://github.com/Pycord-Development/pycord/pull/1866)) - 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 @@ -28,7 +25,7 @@ These changes are available on the `master` branch, but have not yet been releas ([#1936](https://github.com/Pycord-Development/pycord/pull/1936)) - 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(). +- 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`. ([#1992](https://github.com/Pycord-Development/pycord/pull/1992)) @@ -46,11 +43,11 @@ These changes are available on the `master` branch, but have not yet been releas - Added and documented missing `AuditLogAction` enums. ([#2030](https://github.com/Pycord-Development/pycord/pull/2030), [#2171](https://github.com/Pycord-Development/pycord/pull/2171)) -- `AuditLogDiff` now supports AutoMod related models. +- Added AutoMod-related models for `AuditLogDiff` enums. ([#2030](https://github.com/Pycord-Development/pycord/pull/2030)) - Added `Interaction.respond` and `Interaction.edit` as shortcut responses. ([#2026](https://github.com/Pycord-Development/pycord/pull/2026)) -- Added `view.parent` which is set when the view was sent by +- 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` & @@ -67,13 +64,19 @@ These changes are available on the `master` branch, but have not yet been releas ([#2102](https://github.com/Pycord-Development/pycord/pull/2102)) - Added `bridge.Context` as a shortcut to `Union` of subclasses. ([#2106](https://github.com/Pycord-Development/pycord/pull/2106)) -- Added Annotated forms support for typehinting slash command options. +- Added Annotated forms support for type-hinting slash command options. ([#2124](https://github.com/Pycord-Development/pycord/pull/2124)) - Added `suppress` and `allowed_mentions` parameters to `Webhook` and `InteractionResponse` edit methods. ([#2138](https://github.com/Pycord-Development/pycord/pull/2138)) - Added `wait_finish` parameter to `VoiceClient.play` for awaiting the end of a play. ([#2194](https://github.com/Pycord-Development/pycord/pull/2194)) +- Added support for custom bot status. + ([#2206](https://github.com/Pycord-Development/pycord/pull/2206)) +- Added function `Guild.delete_auto_moderation_rule`. + ([#2153](https://github.com/Pycord-Development/pycord/pull/2153)) +- Added `VoiceChannel.slowmode_delay`. + ([#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 @@ -82,26 +85,33 @@ These changes are available on the `master` branch, but have not yet been releas ### Changed -- Suppressed FFMPEG output when recording voice channels. +- Changed default for all `name_localizations` & `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. ([#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)) -- `Interaction.channel` is received from the gateway, so it can now be `DMChannel` and - `GroupChannel`. ([#2025](https://github.com/Pycord-Development/pycord/pull/2025)) -- `DMChannel.recipients` can now be `None`. +- Changed the behavior of retrieving bans to accurately reflect the API. + ([#1922](https://github.com/Pycord-Development/pycord/pull/1922)) +- Changed `Interaction.channel` to be received from the gateway, allowing it to be + `DMChannel` or `GroupChannel`. ([#2025](https://github.com/Pycord-Development/pycord/pull/2025)) -- Store `view.message` on receiving Interaction for a component. - ([#2036](https://github.com/Pycord-Development/pycord/pull/2036)) -- Attributes shared between ext and slash commands are now dynamically fetched on bridge - commands. ([#1867](https://github.com/Pycord-Development/pycord/pull/1867)) -- Embed attribues like author, footer, etc now return `None` when not set, and return - their respective classes when set. +- 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 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. ([#2063](https://github.com/Pycord-Development/pycord/pull/2063)) -- `default_avatar` behavior changes depending on the user's username migration status. +- Changed `default_avatar` behavior depending on the user's username migration status. ([#2087](https://github.com/Pycord-Development/pycord/pull/2087)) -- Typehinted `command_prefix` and `help_command` arguments properly. +- Changed type-hinted `command_prefix` and `help_command` arguments properly. ([#2099](https://github.com/Pycord-Development/pycord/pull/2099)) -- Replace `orjson` support with `msgspec` support. +- Changed the support from `orjson` to `msgspec` in the codebase. ([#2170](https://github.com/Pycord-Development/pycord/pull/2170)) ### Removed @@ -128,29 +138,30 @@ These changes are available on the `master` branch, but have not yet been releas ([#1994](https://github.com/Pycord-Development/pycord/pull/1994)) - Fixed scheduled events breaking when changing the location from external to a channel. ([#1998](https://github.com/Pycord-Development/pycord/pull/1998)) -- Fixed boolean converter breaking for bridge commands. Fix bridge command Options not - working. ([#1999](https://github.com/Pycord-Development/pycord/pull/1999)) +- Fixed boolean converter breaking for Bridge Commands. + ([#1999](https://github.com/Pycord-Development/pycord/pull/1999)) +- 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)) -- Fixed `TypeError` in AutoModRule. +- Fixed `TypeError` in `AutoModRule`. ([#2029](https://github.com/Pycord-Development/pycord/pull/2029)) -- Reflecting the api for gettings bans correctly. - ([#1922](https://github.com/Pycord-Development/pycord/pull/1922)) -- Restored functionality for overriding default `on_application_command_error` via - listeners. ([#2044](https://github.com/Pycord-Development/pycord/pull/2044)) -- Fixed unloading of cogs having bridge commands. +- 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. ([#2048](https://github.com/Pycord-Development/pycord/pull/2048)) -- Fixed the Slash command syncronization method `indiviual`. +- Fixed the Slash Command synchronization method `individual`. ([#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)) -- Fixed major TypeError when an AuditLogEntry has no user. +- Fixed major `TypeError` when an `AuditLogEntry` has no user. ([#2079](https://github.com/Pycord-Development/pycord/pull/2079)) - Fixed `HTTPException` when trying to create a forum thread with files. ([#2075](https://github.com/Pycord-Development/pycord/pull/2075)) - Fixed `before_invoke` not being run for `SlashCommandGroup`. ([#2091](https://github.com/Pycord-Development/pycord/pull/2091)) -- Fixed `AttributeError` when accessing a `Select`'s values when it hasn't been +- Fixed `AttributeError` when accessing a `Select` object's values when it hasn't been interacted with. ([#2104](https://github.com/Pycord-Development/pycord/pull/2104)) - Fixed `before_invoke` being run twice for slash subcommands. ([#2139](https://github.com/Pycord-Development/pycord/pull/2139)) @@ -158,17 +169,38 @@ 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 typehinting - of `User` or `Member`. +- 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 `send` method in - `Webhook` class. ([#2156](https://github.com/Pycord-Development/pycord/pull/2156)) +- Fixed missing `delete_after` parameter in overload type-hinting for `Webhook.send()`. + ([#2156](https://github.com/Pycord-Development/pycord/pull/2156)) - Fixed `ScheduledEvent.creator_id` returning `str` instead of `int`. ([#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]`. + ([#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. + ([#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)) +- Fixed `AttributeError` when running permission checks without the `bot` scope. + ([#2113](https://github.com/Pycord-Development/pycord/issues/2113)) +- Fixed `Option` not working on bridge commands because `ext.commands.Command` doesn't + recognize them. ([#2256](https://github.com/Pycord-Development/pycord/pull/2256)) +- Fixed offset-aware tasks causing `TypeError` when being prepared. + ([#2271](https://github.com/Pycord-Development/pycord/pull/2271)) +- Fixed `AttributeError` when serializing commands with `Annotated` type hints. + ([#2243](https://github.com/Pycord-Development/pycord/pull/2243)) +- Fixed `Intents.all()` returning the wrong value. + ([#2257](https://github.com/Pycord-Development/pycord/issues/2257)) ## [2.4.1] - 2023-03-20 @@ -182,10 +214,11 @@ These changes are available on the `master` branch, but have not yet been releas - Fixed the type-hinting of `SlashCommandGroup.walk_commands()` to reflect actual behavior. ([#1838](https://github.com/Pycord-Development/pycord/pull/1838)) -- Fixed the voice ip discovery due to the recent +- Fixed the voice IP discovery due to the recent [announced change](https://discord.com/channels/613425648685547541/697138785317814292/1080623873629884486). ([#1955](https://github.com/Pycord-Development/pycord/pull/1955)) -- Fixed `reason` being passed to wrong method in `guild.create_auto_moderation_rule`. +- Fixed `reason` being passed to the wrong method in + `guild.create_auto_moderation_rule`. ([#1960](https://github.com/Pycord-Development/pycord/pull/1960)) ## [2.4.0] - 2023-02-10 @@ -312,7 +345,7 @@ These changes are available on the `master` branch, but have not yet been releas ### Fixed -- Fixed `parent` attribute of second level subcommands being set to the base level +- Fixed `parent` attribute of second-level subcommands being set to the base level command instead of the direct parent. ([#1673](https://github.com/Pycord-Development/pycord/pull/1673)) @@ -340,7 +373,7 @@ These changes are available on the `master` branch, but have not yet been releas ([#1613](https://github.com/Pycord-Development/pycord/pull/1613)) - `suppress` kwarg to `Messageable.send()`. ([#1587](https://github.com/Pycord-Development/pycord/pull/1587)) -- `proxy` and `proxy_auth` params to many Webhook related methods. +- `proxy` and `proxy_auth` params to many Webhook-related methods. ([#1655](https://github.com/Pycord-Development/pycord/pull/1655)) - `delete_message_seconds` parameter in ban methods. ([#1557](https://github.com/Pycord-Development/pycord/pull/1557)) @@ -470,7 +503,7 @@ These changes are available on the `master` branch, but have not yet been releas `description`. ([#1546](https://github.com/Pycord-Development/pycord/pull/1546)) - Fix threads created with a base message being set to the wrong `message_reference`. ([#1551](https://github.com/Pycord-Development/pycord/pull/1551)) -- Avoid unnecessary call to `sync_commands` during runtime. +- Avoid unnecessary calls to `sync_commands` during runtime. ([#1563](https://github.com/Pycord-Development/pycord/pull/1563)) - Fix bug in `Modal.on_timeout()` by using `custom_id` to create timeout task. ([#1562](https://github.com/Pycord-Development/pycord/pull/1562)) @@ -565,7 +598,7 @@ These changes are available on the `master` branch, but have not yet been releas ([#1386](https://github.com/Pycord-Development/pycord/pull/1386)) - Fix `remove_application_command` not always removing commands. ([#1391](https://github.com/Pycord-Development/pycord/pull/1391)) -- Fix busy-loop in `DecodeManager` when decode queue is empty, causing 100% CPU +- Fix busy-loop in `DecodeManager` when the decode queue is empty, causing 100% CPU consumption. ([#1395](https://github.com/Pycord-Development/pycord/pull/1395)) - Fix incorrect activities and permissions on `Interaction` and `Option` objects. ([#1365](https://github.com/Pycord-Development/pycord/pull/1365)) @@ -585,7 +618,7 @@ These changes are available on the `master` branch, but have not yet been releas ([#1453](https://github.com/Pycord-Development/pycord/pull/1453)) - Update `thread.members` on `thread.fetch_members`. ([#1464](https://github.com/Pycord-Development/pycord/pull/1464)) -- Fix error when discord doesn't send the `app_permissions` data in `Interaction`. +- Fix the error when Discord doesn't send the `app_permissions` data in `Interaction`. ([#1467](https://github.com/Pycord-Development/pycord/pull/1467)) - Fix AttributeError when voice client `play()` function isn't completed yet. ([#1360](https://github.com/Pycord-Development/pycord/pull/1360)) @@ -607,10 +640,10 @@ These changes are available on the `master` branch, but have not yet been releas ([#1181](https://github.com/Pycord-Development/pycord/pull/1181)) - Option names and descriptions are now validated locally. ([#1271](https://github.com/Pycord-Development/pycord/pull/1271)) -- Component field limits are now enforced at library-level +- Component field limits are now enforced at the library level ([#1065](https://github.com/Pycord-Development/pycord/pull/1065) & [#1289](https://github.com/Pycord-Development/pycord/pull/1289)) -- Support providing option channel types as list. +- Support providing option channel types as a list. ([#1000](https://github.com/Pycord-Development/pycord/pull/1000)) - New `Guild.jump_url` property. ([#1282](https://github.com/Pycord-Development/pycord/pull/1282)) @@ -646,7 +679,7 @@ These changes are available on the `master` branch, but have not yet been releas - Removed implicit defer call in `View`. ([#1260](https://github.com/Pycord-Development/pycord/pull/1260)) -- `Option` class and usage was rewritten. +- `Option` class and usage were rewritten. ([#1251](https://github.com/Pycord-Development/pycord/pull/1251)) - `description` argument of `PageGroup` is now optional. ([#1330](https://github.com/Pycord-Development/pycord/pull/1330)) @@ -661,7 +694,7 @@ These changes are available on the `master` branch, but have not yet been releas ([#1256](https://github.com/Pycord-Development/pycord/pull/1256)) - Fix channel parsing in slash command invocations. ([#1257](https://github.com/Pycord-Development/pycord/pull/1257)) -- Make channel `position` attribute optional. +- Make the channel `position` attribute optional. ([#1257](https://github.com/Pycord-Development/pycord/pull/1257)) - Fix `PaginatorMenu` to use interaction routes for updates. ([#1267](https://github.com/Pycord-Development/pycord/pull/1267)) @@ -673,17 +706,17 @@ These changes are available on the `master` branch, but have not yet been releas ([#1262](https://github.com/Pycord-Development/pycord/pull/1262)) - Fix interaction response race condition. ([#1039](https://github.com/Pycord-Development/pycord/pull/1039)) -- Remove voice client when bot disconnects. +- Remove voice client when the bot disconnects. ([#1273](https://github.com/Pycord-Development/pycord/pull/1273)) -- Fix conversion exception in ext.bridge. +- Fix conversion exception in `ext.bridge`. ([#1250](https://github.com/Pycord-Development/pycord/pull/1250)) -- Context.me return ClientUser when guilds intent is absent. +- `Context.me` returns ClientUser when guilds intent is absent. ([#1286](https://github.com/Pycord-Development/pycord/pull/1286)) -- Updated `Message.edit` type hinting overload and removed resulting redundant +- Updated `Message.edit` type-hinting overload and removed resulting redundant overloads. ([#1299](https://github.com/Pycord-Development/pycord/pull/1299)) - Improved validation regex for command names & options. ([#1309](https://github.com/Pycord-Development/pycord/pull/1309)) -- Correct `Guild.fetch_members()` type hints. +- Correct `Guild.fetch_members()` type-hints. ([#1323](https://github.com/Pycord-Development/pycord/pull/1323)) - Multiple fixes and enhancements for `PageGroup` handling. ([#1350](https://github.com/Pycord-Development/pycord/pull/1350)) diff --git a/discord/abc.py b/discord/abc.py index fab9917329..ce811492bc 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -735,7 +735,7 @@ def permissions_for(self, obj: Member | Role, /) -> Permissions: return Permissions.all() default = self.guild.default_role - base = Permissions(default.permissions.value) + base = Permissions(default.permissions.value if default else 0) # Handle the role case first if isinstance(obj, Role): diff --git a/discord/activity.py b/discord/activity.py index a00add5cd8..96b20255a8 100644 --- a/discord/activity.py +++ b/discord/activity.py @@ -160,7 +160,7 @@ class Activity(BaseActivity): type: :class:`ActivityType` The type of activity currently being done. state: Optional[:class:`str`] - The user's current state. For example, "In Game". + The user's current party status or text used for a custom status. details: Optional[:class:`str`] The detail of the user's current activity. timestamps: Dict[:class:`str`, :class:`int`] @@ -229,7 +229,6 @@ def __init__(self, **kwargs): self.assets: ActivityAssets = kwargs.pop("assets", {}) self.party: ActivityParty = kwargs.pop("party", {}) self.application_id: int | None = _get_as_snowflake(kwargs, "application_id") - self.name: str | None = kwargs.pop("name", None) self.url: str | None = kwargs.pop("url", None) self.flags: int = kwargs.pop("flags", 0) self.sync_id: str | None = kwargs.pop("sync_id", None) @@ -242,6 +241,9 @@ def __init__(self, **kwargs): if isinstance(activity_type, ActivityType) else try_enum(ActivityType, activity_type) ) + self.name: str | None = kwargs.pop( + "name", "Custom Status" if self.type == ActivityType.custom else None + ) emoji = kwargs.pop("emoji", None) self.emoji: PartialEmoji | None = ( @@ -252,6 +254,7 @@ def __repr__(self) -> str: attrs = ( ("type", self.type), ("name", self.name), + ("state", self.state), ("url", self.url), ("details", self.details), ("application_id", self.application_id), @@ -760,6 +763,8 @@ class CustomActivity(BaseActivity): The custom activity's name. emoji: Optional[:class:`PartialEmoji`] The emoji to pass to the activity, if any. + state: Optional[:class:`str`] + The text used for the custom activity. """ __slots__ = ("name", "emoji", "state") @@ -769,7 +774,7 @@ def __init__( ): super().__init__(**extra) self.name: str | None = name - self.state: str | None = extra.pop("state", None) + self.state: str | None = extra.pop("state", name) if self.name == "Custom Status": self.name = self.state diff --git a/discord/bot.py b/discord/bot.py index 5587aef34b..545c11bb8d 100644 --- a/discord/bot.py +++ b/discord/bot.py @@ -781,8 +781,8 @@ async def on_connect(): lambda cmd: cmd.name == i["name"] and cmd.type == i.get("type") and cmd.guild_ids is not None - # TODO: fix this type error (guild_id is not defined in ApplicationCommand Typed Dict) - and int(i["guild_id"]) in cmd.guild_ids, # type: ignore + and (guild_id := i.get("guild_id")) + and guild_id in cmd.guild_ids, self.pending_application_commands, ) if not cmd: diff --git a/discord/channel.py b/discord/channel.py index 3323e19834..93925b29a9 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -1350,6 +1350,7 @@ class VocalGuildChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hasha "user_limit", "_state", "position", + "slowmode_delay", "_overwrites", "category_id", "rtc_region", @@ -1397,6 +1398,7 @@ def _update( data, "last_message_id" ) self.position: int = data.get("position") + self.slowmode_delay = data.get("rate_limit_per_user", 0) self.bitrate: int = data.get("bitrate") self.user_limit: int = data.get("user_limit") self.flags: ChannelFlags = ChannelFlags._from_value(data.get("flags", 0)) @@ -1504,6 +1506,13 @@ class VoiceChannel(discord.abc.Messageable, VocalGuildChannel): The ID of the last message sent to this channel. It may not always point to an existing or valid message. .. versionadded:: 2.0 + slowmode_delay: :class:`int` + The number of seconds a member must wait between sending messages + in this channel. A value of `0` denotes that it is disabled. + Bots and users with :attr:`~Permissions.manage_channels` or + :attr:`~Permissions.manage_messages` bypass slowmode. + + .. versionadded:: 2.5 flags: :class:`ChannelFlags` Extra features of the channel. @@ -1812,6 +1821,7 @@ async def edit( overwrites: Mapping[Role | Member, PermissionOverwrite] = ..., rtc_region: VoiceRegion | None = ..., video_quality_mode: VideoQualityMode = ..., + slowmode_delay: int = ..., reason: str | None = ..., ) -> VoiceChannel | None: ... @@ -2838,7 +2848,7 @@ def __init__( self._state: ConnectionState = state self.recipient: User | None = None if r := data.get("recipients"): - self.recipient: state.store_user(r[0]) + self.recipient = state.store_user(r[0]) self.me: ClientUser = me self.id: int = int(data["id"]) diff --git a/discord/commands/core.py b/discord/commands/core.py index d53bac0d71..c7bd4efd40 100644 --- a/discord/commands/core.py +++ b/discord/commands/core.py @@ -746,10 +746,12 @@ def _parse_options(self, params, *, check_params: bool = True) -> list[Option]: option = next(option_gen, Option()) # Handle Optional if self._is_typing_optional(type_hint): - option.input_type = get_args(type_hint)[0] + option.input_type = SlashCommandOptionType.from_datatype( + get_args(type_hint)[0] + ) option.default = None else: - option.input_type = type_hint + option.input_type = SlashCommandOptionType.from_datatype(type_hint) if self._is_typing_union(option): if self._is_typing_optional(option): diff --git a/discord/enums.py b/discord/enums.py index f4b44623b0..f2bb6d3452 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -67,6 +67,7 @@ "AutoModActionType", "AutoModKeywordPresetType", "ApplicationRoleConnectionMetadataType", + "ReactionType", ) @@ -944,6 +945,13 @@ class ApplicationRoleConnectionMetadataType(Enum): boolean_not_equal = 8 +class ReactionType(Enum): + """The reaction type""" + + normal = 0 + burst = 1 + + T = TypeVar("T") diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index d3ce2e07db..c2282d28bf 100644 --- a/discord/ext/commands/core.py +++ b/discord/ext/commands/core.py @@ -45,6 +45,7 @@ from ...commands import ( ApplicationCommand, + Option, _BaseCommand, message_command, slash_command, @@ -562,7 +563,13 @@ async def dispatch_error(self, ctx: Context, error: Exception) -> None: ctx.bot.dispatch("command_error", ctx, error) async def transform(self, ctx: Context, param: inspect.Parameter) -> Any: - required = param.default is param.empty + if isinstance(param.annotation, Option): + default = param.annotation.default + required = param.annotation.required + else: + default = param.default + required = default is param.empty + converter = get_converter(param) consume_rest_is_special = ( param.kind == param.KEYWORD_ONLY and not self.rest_is_raw @@ -599,7 +606,7 @@ async def transform(self, ctx: Context, param: inspect.Parameter) -> Any: ): return await converter._construct_default(ctx) raise MissingRequiredArgument(param) - return param.default + return default previous = view.index if consume_rest_is_special: diff --git a/discord/ext/tasks/__init__.py b/discord/ext/tasks/__init__.py index 400786d8a4..638bd831c6 100644 --- a/discord/ext/tasks/__init__.py +++ b/discord/ext/tasks/__init__.py @@ -575,7 +575,7 @@ def _get_next_sleep_time(self) -> datetime.datetime: if self._current_loop == 0: # if we're at the last index on the first iteration, we need to sleep until tomorrow return datetime.datetime.combine( - datetime.datetime.now(datetime.timezone.utc) + datetime.datetime.now(self._time[0].tzinfo or datetime.timezone.utc) + datetime.timedelta(days=1), self._time[0], ) @@ -584,18 +584,26 @@ def _get_next_sleep_time(self) -> datetime.datetime: if self._current_loop == 0: self._time_index += 1 - if next_time > datetime.datetime.now(datetime.timezone.utc).timetz(): + if ( + next_time + > datetime.datetime.now( + next_time.tzinfo or datetime.timezone.utc + ).timetz() + ): return datetime.datetime.combine( - datetime.datetime.now(datetime.timezone.utc), next_time + datetime.datetime.now(next_time.tzinfo or datetime.timezone.utc), + next_time, ) else: return datetime.datetime.combine( - datetime.datetime.now(datetime.timezone.utc) + datetime.datetime.now(next_time.tzinfo or datetime.timezone.utc) + datetime.timedelta(days=1), next_time, ) - next_date = cast(datetime.datetime, self._last_iteration) + next_date = cast( + datetime.datetime, self._last_iteration.astimezone(next_time.tzinfo) + ) if next_time < next_date.timetz(): next_date += datetime.timedelta(days=1) @@ -611,9 +619,9 @@ def _prepare_time_index(self, now: datetime.datetime = MISSING) -> None: now if now is not MISSING else datetime.datetime.now(datetime.timezone.utc).replace(microsecond=0) - ).timetz() + ) for idx, time in enumerate(self._time): - if time >= time_now: + if time >= time_now.astimezone(time.tzinfo).timetz(): self._time_index = idx break else: diff --git a/discord/flags.py b/discord/flags.py index 308083d673..9f687ff9bc 100644 --- a/discord/flags.py +++ b/discord/flags.py @@ -636,8 +636,8 @@ def __init__(self, **kwargs: bool): @classmethod def all(cls: type[Intents]) -> Intents: """A factory method that creates a :class:`Intents` with everything enabled.""" - bits = max(cls.VALID_FLAGS.values()).bit_length() - value = (1 << bits) - 1 + value = sum({1 << (flag.bit_length() - 1) for flag in cls.VALID_FLAGS.values()}) + self = cls.__new__(cls) self.value = value return self diff --git a/discord/guild.py b/discord/guild.py index 2128de6ba4..f2ef9aa8a0 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -2933,7 +2933,7 @@ async def create_role( if icon is None: fields["icon"] = None else: - fields["icon"] = _bytes_to_base64_data(icon) + fields["icon"] = utils._bytes_to_base64_data(icon) fields["unicode_emoji"] = None if unicode_emoji is not MISSING: @@ -3841,3 +3841,29 @@ async def create_auto_moderation_rule( self.id, payload, reason=reason ) return AutoModRule(state=self._state, data=data) + + async def delete_auto_moderation_rule( + self, + id: int, + *, + reason: str | None = None, + ) -> None: + """ + Deletes an auto moderation rule. + + Parameters + ---------- + id: :class:`int` + The ID of the auto moderation rule. + reason: Optional[:class:`str`] + The reason for deleting the rule. Shows up in the audit log. + + Raises + ------ + HTTPException + Deleting the auto moderation rule failed. + Forbidden + You do not have the Manage Guild permission. + """ + + await self._state.http.delete_auto_moderation_rule(self.id, id, reason=reason) diff --git a/discord/http.py b/discord/http.py index 462ef2c495..30184b665a 100644 --- a/discord/http.py +++ b/discord/http.py @@ -757,6 +757,7 @@ def get_reaction_users( emoji: str, limit: int, after: Snowflake | None = None, + type: int | None = None, ) -> Response[list[user.User]]: r = Route( "GET", @@ -771,6 +772,8 @@ def get_reaction_users( } if after: params["after"] = after + if type: + params["type"] = type return self.request(r, params=params) def clear_reactions( diff --git a/discord/interactions.py b/discord/interactions.py index 83ca14f128..19b5363082 100644 --- a/discord/interactions.py +++ b/discord/interactions.py @@ -149,6 +149,8 @@ class Interaction: "custom_id", "_channel_data", "_message_data", + "_guild_data", + "_guild", "_permissions", "_app_permissions", "_state", @@ -188,6 +190,11 @@ def _from_data(self, data: InteractionPayload): self.user: User | Member | None = None self._permissions: int = 0 + self._guild: Guild | None = None + self._guild_data = data.get("guild") + if self.guild is None and self._guild_data: + self._guild = Guild(data=self._guild_data, state=self) + # TODO: there's a potential data loss here if self.guild_id: guild = ( @@ -246,6 +253,8 @@ def client(self) -> Client: @property def guild(self) -> Guild | None: """The guild the interaction was sent from.""" + if self._guild: + return self._guild return self._state and self._state._get_guild(self.guild_id) def is_command(self) -> bool: diff --git a/discord/iterators.py b/discord/iterators.py index 78edb7570d..b171d70ed6 100644 --- a/discord/iterators.py +++ b/discord/iterators.py @@ -182,10 +182,11 @@ async def next(self) -> T: class ReactionIterator(_AsyncIterator[Union["User", "Member"]]): - def __init__(self, message, emoji, limit=100, after=None): + def __init__(self, message, emoji, limit=100, after=None, type=None): self.message = message self.limit = limit self.after = after + self.type = type state = message._state self.getter = state.http.get_reaction_users self.state = state @@ -212,7 +213,12 @@ async def fill_users(self): after = self.after.id if self.after else None data: list[PartialUserPayload] = await self.getter( - self.channel_id, self.message.id, self.emoji, retrieve, after=after + self.channel_id, + self.message.id, + self.emoji, + retrieve, + after=after, + type=self.type, ) if data: diff --git a/discord/player.py b/discord/player.py index 87b0f5718a..0b4dc417c3 100644 --- a/discord/player.py +++ b/discord/player.py @@ -227,7 +227,7 @@ def _pipe_writer(self, source: io.BufferedIOBase) -> None: # arbitrarily large read size data = source.read(8192) if not data: - self._process.terminate() + self._stdin.close() return try: self._stdin.write(data) diff --git a/discord/raw_models.py b/discord/raw_models.py index 1cd88ea0c2..79c8091d98 100644 --- a/discord/raw_models.py +++ b/discord/raw_models.py @@ -29,7 +29,7 @@ from typing import TYPE_CHECKING from .automod import AutoModAction, AutoModTriggerType -from .enums import AuditLogAction, ChannelType, try_enum +from .enums import AuditLogAction, ChannelType, ReactionType, try_enum from .types.user import User if TYPE_CHECKING: @@ -214,6 +214,15 @@ class RawReactionActionEvent(_RawReprMixin): ``REACTION_REMOVE`` for reaction removal. .. versionadded:: 1.3 + burst: :class:`bool` + Whether this reaction is a burst (super) reaction. + burst_colours: Optional[:class:`list`] + A list of hex codes this reaction can be. Only available if `event_type` is `REACTION_ADD` + and this emoji has super reactions available. + burst_colors: Optional[:class:`list`] + Alias for :attr:`burst_colours`. + type: :class:`ReactionType` + The type of reaction added. data: :class:`dict` The raw data sent by the `gateway `_. @@ -226,6 +235,10 @@ class RawReactionActionEvent(_RawReprMixin): "channel_id", "guild_id", "emoji", + "burst", + "burst_colours", + "burst_colors", + "type", "event_type", "member", "data", @@ -240,6 +253,10 @@ def __init__( self.emoji: PartialEmoji = emoji self.event_type: str = event_type self.member: Member | None = None + self.burst: bool = data.get("burst") + self.burst_colours: list = data.get("burst_colors", []) + self.burst_colors: list = self.burst_colours + self.type: ReactionType = try_enum(ReactionType, data.get("type", 0)) try: self.guild_id: int | None = int(data["guild_id"]) @@ -293,18 +310,30 @@ class RawReactionClearEmojiEvent(_RawReprMixin): The guild ID where the reactions got cleared. emoji: :class:`PartialEmoji` The custom or unicode emoji being removed. + burst: :class:`bool` + Whether this reaction was a burst (super) reaction. + burst_colours: :class:`list` + The available HEX codes of the removed super reaction. + burst_colors: Optional[:class:`list`] + Alias for :attr:`burst_colours`. + type: :class:`ReactionType` + The type of reaction removed. data: :class:`dict` The raw data sent by the `gateway `_. .. versionadded:: 2.5 """ - __slots__ = ("message_id", "channel_id", "guild_id", "emoji", "data") + __slots__ = ("message_id", "channel_id", "guild_id", "emoji", "burst", "data") def __init__(self, data: ReactionClearEmojiEvent, emoji: PartialEmoji) -> None: self.emoji: PartialEmoji = emoji self.message_id: int = int(data["message_id"]) self.channel_id: int = int(data["channel_id"]) + self.burst: bool = data.get("burst") + self.burst_colours: list = data.get("burst_colors", []) + self.burst_colors: list = self.burst_colours + self.type: ReactionType = try_enum(ReactionType, data.get("type", 0)) try: self.guild_id: int | None = int(data["guild_id"]) diff --git a/discord/reaction.py b/discord/reaction.py index ea1bcbded9..426b5474ef 100644 --- a/discord/reaction.py +++ b/discord/reaction.py @@ -27,9 +27,11 @@ from typing import TYPE_CHECKING, Any +from .colour import Colour +from .enums import ReactionType from .iterators import ReactionIterator -__all__ = ("Reaction",) +__all__ = ("Reaction", "ReactionCountDetails") if TYPE_CHECKING: from .abc import Snowflake @@ -37,6 +39,7 @@ from .message import Message from .partial_emoji import PartialEmoji from .types.message import Reaction as ReactionPayload + from .types.message import ReactionCountDetails as ReactionCountDetailsPayload class Reaction: @@ -70,14 +73,27 @@ class Reaction: emoji: Union[:class:`Emoji`, :class:`PartialEmoji`, :class:`str`] The reaction emoji. May be a custom emoji, or a unicode emoji. count: :class:`int` - Number of times this reaction was made + The combined total of normal and super reactions for this emoji. me: :class:`bool` - If the user sent this reaction. + If the user sent this as a normal reaction. + me_burst: :class:`bool` + If the user sent this as a super reaction. message: :class:`Message` Message this reaction is for. + burst: :class:`bool` + Whether this reaction is a burst (super) reaction. """ - __slots__ = ("message", "count", "emoji", "me") + __slots__ = ( + "message", + "count", + "emoji", + "me", + "burst", + "me_burst", + "_count_details", + "_burst_colours", + ) def __init__( self, @@ -91,7 +107,35 @@ def __init__( emoji or message._state.get_reaction_emoji(data["emoji"]) ) self.count: int = data.get("count", 1) + self._count_details: ReactionCountDetailsPayload = data.get("count_details", {}) self.me: bool = data.get("me") + self.burst: bool = data.get("burst") + self.me_burst: bool = data.get("me_burst") + self._burst_colours: list[Colour] = data.get("burst_colors", []) + + @property + def burst_colours(self) -> list[Colour]: + """Returns a list possible :class:`Colour` this super reaction can be. + + There is an alias for this named :attr:`burst_colors`. + """ + + # We recieve a list of #FFFFFF, so omit the # and convert to base 16 + return [Colour(int(c[1:], 16)) for c in self._burst_colours] + + @property + def burst_colors(self) -> list[Colour]: + """Returns a list possible :class:`Colour` this super reaction can be. + + There is an alias for this named :attr:`burst_colours`. + """ + + return self.burst_colours + + @property + def count_details(self): + """Returns :class:`ReactionCountDetails` for the individual counts of normal and super reactions made.""" + return ReactionCountDetails(self._count_details) # TODO: typeguard def is_custom_emoji(self) -> bool: @@ -166,7 +210,11 @@ async def clear(self) -> None: await self.message.clear_reaction(self.emoji) def users( - self, *, limit: int | None = None, after: Snowflake | None = None + self, + *, + limit: int | None = None, + after: Snowflake | None = None, + type: ReactionType | None = None, ) -> ReactionIterator: """Returns an :class:`AsyncIterator` representing the users that have reacted to the message. @@ -181,6 +229,8 @@ def users( reacted to the message. after: Optional[:class:`abc.Snowflake`] For pagination, reactions are sorted by member. + type: Optional[:class:`ReactionType`] + The type of reaction to get users for. Defaults to `normal`. Yields ------ @@ -210,6 +260,10 @@ def users( # users is now a list of User... winner = random.choice(users) await channel.send(f'{winner} has won the raffle.') + + Getting super reactors: :: + + users = await reaction.users(type=ReactionType.burst).flatten() """ if not isinstance(self.emoji, str): @@ -220,4 +274,23 @@ def users( if limit is None: limit = self.count - return ReactionIterator(self.message, emoji, limit, after) + if isinstance(type, ReactionType): + type = type.value + + return ReactionIterator(self.message, emoji, limit, after, type) + + +class ReactionCountDetails: + """Represents a breakdown of the normal and burst reaction counts for the emoji. + + Attributes + ---------- + normal: :class:`int` + The number of normal reactions for this emoji. + burst: :class:`bool` + The number of super reactions for this emoji. + """ + + def __init__(self, data: ReactionCountDetailsPayload): + self.normal = data.get("normal", 0) + self.burst = data.get("burst", 0) diff --git a/discord/types/interactions.py b/discord/types/interactions.py index ad891e3203..db66489067 100644 --- a/discord/types/interactions.py +++ b/discord/types/interactions.py @@ -47,35 +47,45 @@ class ApplicationCommand(TypedDict): - options: NotRequired[list[ApplicationCommandOption]] - type: NotRequired[ApplicationCommandType] - name_localized: NotRequired[str] - name_localizations: NotRequired[dict[str, str]] - description_localized: NotRequired[str] - description_localizations: NotRequired[dict[str, str]] id: Snowflake + type: NotRequired[ApplicationCommandType] application_id: Snowflake + guild_id: NotRequired[Snowflake] name: str + name_localizations: NotRequired[dict[str, str] | None] description: str + description_localizations: NotRequired[dict[str, str] | None] + options: NotRequired[list[ApplicationCommandOption]] + default_member_permissions: str | None + dm_permission: NotRequired[bool] + default_permission: NotRequired[bool | None] + nsfw: NotRequired[bool] + version: Snowflake ApplicationCommandOptionType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] class ApplicationCommandOption(TypedDict): - choices: NotRequired[list[ApplicationCommandOptionChoice]] - options: NotRequired[list[ApplicationCommandOption]] - name_localizations: NotRequired[dict[str, str]] - description_localizations: NotRequired[dict[str, str]] type: ApplicationCommandOptionType name: str + name_localizations: NotRequired[dict[str, str] | None] description: str + description_localizations: NotRequired[dict[str, str] | None] required: bool + options: NotRequired[list[ApplicationCommandOption]] + choices: NotRequired[list[ApplicationCommandOptionChoice]] + channel_types: NotRequired[list[ChannelType]] + min_value: NotRequired[int | float] + max_value: NotRequired[int | float] + min_length: NotRequired[int] + max_length: NotRequired[int] + autocomplete: NotRequired[bool] class ApplicationCommandOptionChoice(TypedDict): - name_localizations: NotRequired[dict[str, str]] name: str + name_localizations: NotRequired[dict[str, str] | None] value: str | int diff --git a/discord/types/message.py b/discord/types/message.py index b141531e9a..93e99ba7ab 100644 --- a/discord/types/message.py +++ b/discord/types/message.py @@ -54,6 +54,12 @@ class Reaction(TypedDict): count: int me: bool emoji: PartialEmoji + burst: bool + + +class ReactionCountDetails(TypedDict): + normal: int + burst: int class Attachment(TypedDict): diff --git a/discord/types/raw_models.py b/discord/types/raw_models.py index 453e75cf17..44ac45363d 100644 --- a/discord/types/raw_models.py +++ b/discord/types/raw_models.py @@ -62,6 +62,9 @@ class ReactionActionEvent(_ReactionEventOptional): channel_id: Snowflake message_id: Snowflake emoji: PartialEmoji + burst: bool + burst_colors: list + type: int class ReactionClearEvent(_ReactionEventOptional): @@ -73,6 +76,9 @@ class ReactionClearEmojiEvent(_ReactionEventOptional): channel_id: int message_id: int emoji: PartialEmoji + burst: bool + burst_colors: list + type: int class IntegrationDeleteEvent(TypedDict): diff --git a/docs/api/enums.rst b/docs/api/enums.rst index e2620ed8e5..45317a37ce 100644 --- a/docs/api/enums.rst +++ b/docs/api/enums.rst @@ -2292,3 +2292,17 @@ of :class:`enum.Enum`. .. attribute:: slurs Represents the slurs keyword preset rule. + +.. class:: ReactionType + + Represents a Reaction's type. + + .. versionadded:: 2.5 + + .. attribute:: normal + + Represents a normal reaction. + + .. attribute:: burst + + Represents a super reaction. diff --git a/docs/api/models.rst b/docs/api/models.rst index 909853a769..4d11fed63e 100644 --- a/docs/api/models.rst +++ b/docs/api/models.rst @@ -98,6 +98,9 @@ Messages .. automethod:: users :async-for: +.. autoclass:: ReactionCountDetails() + :members: + Guild ----- diff --git a/requirements/_.txt b/requirements/_.txt index 26e696d0f2..2488d446e6 100644 --- a/requirements/_.txt +++ b/requirements/_.txt @@ -1,2 +1,2 @@ -aiohttp>=3.6.0,<3.9.0 +aiohttp>=3.6.0,<3.10.0 typing_extensions>=4,<5; python_version < "3.11" diff --git a/requirements/dev.txt b/requirements/dev.txt index 2e9fac2a7c..3c71378e73 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,11 +1,11 @@ -r _.txt -pylint~=2.17.5 -pytest~=7.4.0 -pytest-asyncio~=0.21.1 +pylint~=3.0.3 +pytest~=7.4.3 +pytest-asyncio~=0.23.2 # pytest-order~=1.0.1 -mypy~=1.5.0 -coverage~=7.2 -pre-commit==3.3.3 -codespell==2.2.5 -bandit==1.7.5 +mypy~=1.7.1 +coverage~=7.3 +pre-commit==3.5.0 +codespell==2.2.6 +bandit==1.7.6 flake8==6.1.0 diff --git a/requirements/docs.txt b/requirements/docs.txt index 453c4fcf7b..2c8cb6ede3 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -2,7 +2,7 @@ sphinx==5.3.0 sphinxcontrib_trio==1.1.2 sphinxcontrib-websupport==1.2.4 myst-parser==1.0.0 -sphinxext-opengraph==0.8.2 +sphinxext-opengraph==0.9.0 sphinx-copybutton==0.5.2 furo@ git+https://github.com/pradyunsg/furo@193643f sphinx-autodoc-typehints==1.23.0 diff --git a/requirements/speed.txt b/requirements/speed.txt index 32c37acb7a..d4ce69e7e6 100644 --- a/requirements/speed.txt +++ b/requirements/speed.txt @@ -1,2 +1,2 @@ -msgspec~=0.18.0 +msgspec~=0.18.5 aiohttp[speedups] diff --git a/tests/test_typing_annotated.py b/tests/test_typing_annotated.py index 582bd4f8a0..7091a241ff 100644 --- a/tests/test_typing_annotated.py +++ b/tests/test_typing_annotated.py @@ -1,10 +1,9 @@ from typing import Optional -import pytest from typing_extensions import Annotated import discord -from discord import ApplicationContext +from discord import SlashCommandOptionType from discord.commands.core import SlashCommand, slash_command @@ -15,6 +14,10 @@ async def echo(ctx, txt: Annotated[str, discord.Option()]): cmd = SlashCommand(echo) bot = discord.Bot() bot.add_application_command(cmd) + dict_result = cmd.to_dict() + assert ( + dict_result.get("options")[0].get("type") == SlashCommandOptionType.string.value + ) def test_typing_annotated_decorator(): @@ -24,6 +27,12 @@ def test_typing_annotated_decorator(): async def echo(ctx, txt: Annotated[str, discord.Option(description="Some text")]): await ctx.respond(txt) + dict_result = echo.to_dict() + + option = dict_result.get("options")[0] + assert option.get("type") == SlashCommandOptionType.string.value + assert option.get("description") == "Some text" + def test_typing_annotated_cog(): class echoCog(discord.Cog): @@ -38,7 +47,14 @@ async def echo( await ctx.respond(txt) bot = discord.Bot() - bot.add_cog(echoCog(bot)) + cog = echoCog(bot) + bot.add_cog(cog) + + dict_result = cog.echo.to_dict() + + option = dict_result.get("options")[0] + assert option.get("type") == SlashCommandOptionType.string.value + assert option.get("description") == "Some text" def test_typing_annotated_cog_slashgroup(): @@ -56,7 +72,14 @@ async def echo( await ctx.respond(txt) bot = discord.Bot() - bot.add_cog(echoCog(bot)) + cog = echoCog(bot) + bot.add_cog(cog) + + dict_result = cog.echo.to_dict() + + option = dict_result.get("options")[0] + assert option.get("type") == SlashCommandOptionType.string.value + assert option.get("description") == "Some text" def test_typing_annotated_optional(): @@ -67,6 +90,11 @@ async def echo(ctx, txt: Annotated[Optional[str], discord.Option()]): bot = discord.Bot() bot.add_application_command(cmd) + dict_result = cmd.to_dict() + + option = dict_result.get("options")[0] + assert option.get("type") == SlashCommandOptionType.string.value + def test_no_annotation(): async def echo(ctx, txt: str): @@ -76,6 +104,11 @@ async def echo(ctx, txt: str): bot = discord.Bot() bot.add_application_command(cmd) + dict_result = cmd.to_dict() + + option = dict_result.get("options")[0] + assert option.get("type") == SlashCommandOptionType.string.value + def test_annotated_no_option(): async def echo(ctx, txt: Annotated[str, "..."]): @@ -84,3 +117,8 @@ async def echo(ctx, txt: Annotated[str, "..."]): cmd = SlashCommand(echo) bot = discord.Bot() bot.add_application_command(cmd) + + dict_result = cmd.to_dict() + + option = dict_result.get("options")[0] + assert option.get("type") == SlashCommandOptionType.string.value