From 73e71737c1c06fd964a6fa7b1439982f454c6fb4 Mon Sep 17 00:00:00 2001 From: UK <41271523+NeloBlivion@users.noreply.github.com> Date: Wed, 8 Nov 2023 20:44:04 +0000 Subject: [PATCH 01/33] fix: TypeErrors raised from Reaction events (#2255) fix try_enum --- discord/raw_models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/discord/raw_models.py b/discord/raw_models.py index 39eab47443..79c8091d98 100644 --- a/discord/raw_models.py +++ b/discord/raw_models.py @@ -256,7 +256,7 @@ def __init__( 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(data.get("type", 0)) + self.type: ReactionType = try_enum(ReactionType, data.get("type", 0)) try: self.guild_id: int | None = int(data["guild_id"]) @@ -333,7 +333,7 @@ def __init__(self, data: ReactionClearEmojiEvent, emoji: PartialEmoji) -> 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(data.get("type", 0)) + self.type: ReactionType = try_enum(ReactionType, data.get("type", 0)) try: self.guild_id: int | None = int(data["guild_id"]) From 80efff04865c888a93b06b505366477b31d1c871 Mon Sep 17 00:00:00 2001 From: FrederikTheDane <13228251+FrederikTheDane@users.noreply.github.com> Date: Tue, 21 Nov 2023 18:18:50 +0100 Subject: [PATCH 02/33] fix: ffmpeg terminated prematurely (#2240) --- CHANGELOG.md | 2 ++ discord/player.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41f9e96c11..acc9ecc98e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -180,6 +180,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#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)) ## [2.4.1] - 2023-03-20 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) From 31a9692997e1ffc3af34bbaed548f88c27722b20 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 26 Nov 2023 14:54:54 +0000 Subject: [PATCH 03/33] chore(deps-dev): update mypy requirement from ~=1.5.1 to ~=1.7.1 (#2268) Updates the requirements on [mypy](https://github.com/python/mypy) to permit the latest version. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v1.5.1...v1.7.1) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements/dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index 1831a6fd24..525873d774 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -3,7 +3,7 @@ pylint~=2.17.5 pytest~=7.4.3 pytest-asyncio~=0.21.1 # pytest-order~=1.0.1 -mypy~=1.5.1 +mypy~=1.7.1 coverage~=7.3 pre-commit==3.5.0 codespell==2.2.6 From cbcf3ce99f17e242faa447d4e73bddf712e327e0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 26 Nov 2023 09:06:22 -0600 Subject: [PATCH 04/33] chore(deps): update aiohttp requirement from <3.9.0,>=3.6.0 to >=3.6.0,<3.10.0 (#2266) chore(deps): update aiohttp requirement Updates the requirements on [aiohttp](https://github.com/aio-libs/aiohttp) to permit the latest version. - [Release notes](https://github.com/aio-libs/aiohttp/releases) - [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst) - [Commits](https://github.com/aio-libs/aiohttp/compare/v3.6.0...v3.9.0) --- updated-dependencies: - dependency-name: aiohttp dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements/_.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From f6ac77805beac9a6e162478247016f6f0eb32878 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 26 Nov 2023 15:19:55 +0000 Subject: [PATCH 05/33] chore(deps): bump sphinxext-opengraph from 0.8.2 to 0.9.0 (#2250) Bumps [sphinxext-opengraph](https://github.com/wpilibsuite/sphinxext-opengraph) from 0.8.2 to 0.9.0. - [Release notes](https://github.com/wpilibsuite/sphinxext-opengraph/releases) - [Commits](https://github.com/wpilibsuite/sphinxext-opengraph/compare/v0.8.2...v0.9.0) --- updated-dependencies: - dependency-name: sphinxext-opengraph dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements/docs.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 2437c7e2a7ede72376fb77955507d8979807daa0 Mon Sep 17 00:00:00 2001 From: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> Date: Mon, 27 Nov 2023 00:39:17 +0900 Subject: [PATCH 06/33] fix: tasks loop infinitely when `tzinfo` is neither `None` nor UTC (#2196) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Resolve task unlimited repeat bug Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> * Fix bug for first init Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> * fix bug for 2nd or above Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> * add fix to CHANGELOG.md Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> * change : Naive한 경우 누락된 거 수정 Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> * style(pre-commit): auto fixes from pre-commit.com hooks * Update CHANGELOG.md Co-authored-by: JustaSqu1d <89910983+JustaSqu1d@users.noreply.github.com> Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> * style(pre-commit): auto fixes from pre-commit.com hooks * Update discord/ext/tasks/__init__.py Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> * Update discord/ext/tasks/__init__.py Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> * Update discord/ext/tasks/__init__.py Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> * Update discord/ext/tasks/__init__.py Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> * style(pre-commit): auto fixes from pre-commit.com hooks * Update CHANGELOG.md Signed-off-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> * oops Signed-off-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> --------- Signed-off-by: Jeon Hojin <36477282+SorameHato@users.noreply.github.com> Signed-off-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: JustaSqu1d <89910983+JustaSqu1d@users.noreply.github.com> Co-authored-by: Lala Sabathil Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> --- CHANGELOG.md | 2 ++ discord/ext/tasks/__init__.py | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acc9ecc98e..3abc886053 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -182,6 +182,8 @@ These changes are available on the `master` branch, but have not yet been releas `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)) ## [2.4.1] - 2023-03-20 diff --git a/discord/ext/tasks/__init__.py b/discord/ext/tasks/__init__.py index 400786d8a4..81d39ab8d1 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) From ba5a52d27794c14471a5c2e58d3564b064d8ae35 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 Nov 2023 13:19:10 +0000 Subject: [PATCH 07/33] chore(pre-commit): pre-commit autoupdate (#2241) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.4.0...v4.5.0) - [github.com/asottile/pyupgrade: v3.13.0 → v3.15.0](https://github.com/asottile/pyupgrade/compare/v3.13.0...v3.15.0) - [github.com/psf/black: 23.9.1 → 23.11.0](https://github.com/psf/black/compare/23.9.1...23.11.0) - [github.com/pre-commit/mirrors-prettier: v3.0.3 → v3.1.0](https://github.com/pre-commit/mirrors-prettier/compare/v3.0.3...v3.1.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ed38b0797c..e0cd7bbdfe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ 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 @@ -19,7 +19,7 @@ repos: # - --remove-duplicate-keys # - --remove-unused-variables - repo: https://github.com/asottile/pyupgrade - rev: v3.13.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.9.1 + 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.3 + rev: v3.1.0 hooks: - id: prettier args: [--prose-wrap=always, --print-width=88] From 257d61a200e74fea887e81a05684858cb4638750 Mon Sep 17 00:00:00 2001 From: The Darsh <129121284+its-darsh@users.noreply.github.com> Date: Wed, 29 Nov 2023 07:41:32 +0200 Subject: [PATCH 08/33] feat: Add slowmode_delay attribute to discord.VoiceChannel (#2112) * feat: Add slowmode_delay attribute to discord.VoiceChannel adds the `slowmode_delay` attribute to the `discord.VoiceChannel` class. Signed-off-by: DARSH <129121284+DARSHTRON@users.noreply.github.com> * Update CHANGELOG.md Signed-off-by: DARSH <129121284+DARSHTRON@users.noreply.github.com> * style(pre-commit): auto fixes from pre-commit.com hooks * Fix duplicate changelog from pull from master Signed-off-by: Middledot <78228142+Middledot@users.noreply.github.com> * added `versionadded` to docstr Signed-off-by: The Darsh <129121284+its-darsh@users.noreply.github.com> * Update CHANGELOG.md Co-authored-by: plun1331 Signed-off-by: The Darsh <129121284+its-darsh@users.noreply.github.com> * fix: `VoiceChannel` docstr Signed-off-by: The Darsh <129121284+its-darsh@users.noreply.github.com> * style(pre-commit): auto fixes from pre-commit.com hooks * fix: VoiceChannel.slowmode_delay Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Signed-off-by: The Darsh <129121284+its-darsh@users.noreply.github.com> --------- Signed-off-by: DARSH <129121284+DARSHTRON@users.noreply.github.com> Signed-off-by: Middledot <78228142+Middledot@users.noreply.github.com> Signed-off-by: The Darsh <129121284+its-darsh@users.noreply.github.com> Co-authored-by: DARSH <129121284+DARSHTRON@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Middledot <78228142+Middledot@users.noreply.github.com> Co-authored-by: plun1331 Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Co-authored-by: Lala Sabathil --- CHANGELOG.md | 2 ++ discord/channel.py | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3abc886053..463bb1b614 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#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)) ### Changed diff --git a/discord/channel.py b/discord/channel.py index 6121dd5890..5cd70f52f7 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -1329,6 +1329,7 @@ class VocalGuildChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hasha "user_limit", "_state", "position", + "slowmode_delay", "_overwrites", "category_id", "rtc_region", @@ -1376,6 +1377,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)) @@ -1483,6 +1485,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. @@ -1791,6 +1800,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: ... From 99725dd1a09d43c0413b0cae553a582abeaabcc1 Mon Sep 17 00:00:00 2001 From: Middledot <78228142+Middledot@users.noreply.github.com> Date: Wed, 29 Nov 2023 12:31:28 -0500 Subject: [PATCH 09/33] fix(commands): fix permission check edge case (#2253) * fix(commands): permissions error with appcmd scope Refer to #2113 * chore(commands): don't put partial guild in cache * Apply suggestions from code review Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Signed-off-by: Middledot <78228142+Middledot@users.noreply.github.com> * Update CHANGELOG.md Signed-off-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> --------- Signed-off-by: Middledot <78228142+Middledot@users.noreply.github.com> Signed-off-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> --- CHANGELOG.md | 2 ++ discord/abc.py | 2 +- discord/interactions.py | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 463bb1b614..cb2196ab0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -186,6 +186,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#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)) ## [2.4.1] - 2023-03-20 diff --git a/discord/abc.py b/discord/abc.py index 71a307ab87..a7aba7ecc3 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -712,7 +712,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/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: From a7f4adbe59d34be38a361ee546fdc303b6b3bb83 Mon Sep 17 00:00:00 2001 From: Middledot <78228142+Middledot@users.noreply.github.com> Date: Wed, 29 Nov 2023 12:37:55 -0500 Subject: [PATCH 10/33] fix(ext.bridge/commands): default arguments with Option don't work (#2256) * fix(ext.commands): command parsing bug #2089 * changelog: changelog * style(pre-commit): auto fixes from pre-commit.com hooks * Apple code suggestion Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Signed-off-by: Middledot <78228142+Middledot@users.noreply.github.com> --------- Signed-off-by: Middledot <78228142+Middledot@users.noreply.github.com> Signed-off-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> --- CHANGELOG.md | 2 ++ discord/ext/commands/core.py | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb2196ab0c..0ce874899d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -188,6 +188,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#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)) ## [2.4.1] - 2023-03-20 diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index d3ce2e07db..4adb27cad0 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 or default is None + 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: From 7b77e094c40b30b997b1705ce7ff25d1255599b2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 30 Nov 2023 16:33:31 +0000 Subject: [PATCH 11/33] chore(deps-dev): update pylint requirement from ~=2.17.5 to ~=2.17.6 (#2233) Updates the requirements on [pylint](https://github.com/pylint-dev/pylint) to permit the latest version. - [Release notes](https://github.com/pylint-dev/pylint/releases) - [Commits](https://github.com/pylint-dev/pylint/compare/v2.17.5...v2.17.6) --- updated-dependencies: - dependency-name: pylint dependency-type: direct:development ... Signed-off-by: dependabot[bot] Signed-off-by: plun1331 Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: plun1331 --- requirements/dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index 525873d774..bb28382928 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,5 +1,5 @@ -r _.txt -pylint~=2.17.5 +pylint~=2.17.6 pytest~=7.4.3 pytest-asyncio~=0.21.1 # pytest-order~=1.0.1 From 9b4f15a4e6795f1cb8624f9c21823ac26bb525ce Mon Sep 17 00:00:00 2001 From: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Date: Thu, 30 Nov 2023 19:38:21 +0300 Subject: [PATCH 12/33] fix: offset-aware time when preparing tasks (#2271) * fix: offset-aware time when preparing tasks * chore: add changelog entry --- CHANGELOG.md | 2 ++ discord/ext/tasks/__init__.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ce874899d..1d4cefa254 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -190,6 +190,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#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)) ## [2.4.1] - 2023-03-20 diff --git a/discord/ext/tasks/__init__.py b/discord/ext/tasks/__init__.py index 81d39ab8d1..638bd831c6 100644 --- a/discord/ext/tasks/__init__.py +++ b/discord/ext/tasks/__init__.py @@ -619,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: From 70d615d0a9885fdd10bc0dd0191d80b493d97d9c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 04:54:13 +0000 Subject: [PATCH 13/33] chore(deps-dev): update pylint requirement from ~=2.17.6 to ~=3.0.2 (#2272) Updates the requirements on [pylint](https://github.com/pylint-dev/pylint) to permit the latest version. - [Release notes](https://github.com/pylint-dev/pylint/releases) - [Commits](https://github.com/pylint-dev/pylint/compare/v2.17.6...v3.0.2) --- updated-dependencies: - dependency-name: pylint dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements/dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index bb28382928..f77e9309c2 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,5 +1,5 @@ -r _.txt -pylint~=2.17.6 +pylint~=3.0.2 pytest~=7.4.3 pytest-asyncio~=0.21.1 # pytest-order~=1.0.1 From 5849d6487b56eaf8d82bd728bab2a89f215fa575 Mon Sep 17 00:00:00 2001 From: Mihitoko <66904140+Mihitoko@users.noreply.github.com> Date: Fri, 1 Dec 2023 18:46:25 +0100 Subject: [PATCH 14/33] fix: attribute error in command serialization (#2243) * use SlashCommandOptionType when parsing options * add assertions to test right serialization of command * update CHANGELOG * put change into right place in CHANGELOG * style(pre-commit): auto fixes from pre-commit.com hooks * Update CHANGELOG.md Signed-off-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> --------- Signed-off-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Signed-off-by: plun1331 Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Co-authored-by: plun1331 --- CHANGELOG.md | 2 ++ discord/commands/core.py | 6 +++-- tests/test_typing_annotated.py | 46 +++++++++++++++++++++++++++++++--- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d4cefa254..4444d79d1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -192,6 +192,8 @@ These changes are available on the `master` branch, but have not yet been releas 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)) ## [2.4.1] - 2023-03-20 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/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 From 6bfae7fa8a17d5795cd9c0b2688dc6810a5b76f1 Mon Sep 17 00:00:00 2001 From: Aito Stukas Date: Sun, 3 Dec 2023 07:41:36 +1100 Subject: [PATCH 15/33] fix: Fixed `discord.Intents.all()` returning the wrong value. (#2257) * Fixed bug! * Fixed Bug! * added bug fix to change log * style(pre-commit): auto fixes from pre-commit.com hooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- CHANGELOG.md | 2 ++ discord/flags.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4444d79d1a..02294de6da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -194,6 +194,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#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 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 From f32cf5df688853f1c68def8bd97c52372c95d367 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Dec 2023 06:43:26 +0000 Subject: [PATCH 16/33] chore(deps-dev): update pytest-asyncio requirement from ~=0.21.1 to ~=0.23.2 (#2278) chore(deps-dev): update pytest-asyncio requirement Updates the requirements on [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) to permit the latest version. - [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases) - [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.21.1...v0.23.2) --- updated-dependencies: - dependency-name: pytest-asyncio dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements/dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index f77e9309c2..801aa1d698 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,7 +1,7 @@ -r _.txt pylint~=3.0.2 pytest~=7.4.3 -pytest-asyncio~=0.21.1 +pytest-asyncio~=0.23.2 # pytest-order~=1.0.1 mypy~=1.7.1 coverage~=7.3 From d5355c45f95c722cb2b422c24710a882af516627 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Dec 2023 06:04:03 +0000 Subject: [PATCH 17/33] ci(deps): bump actions/setup-python from 4 to 5 (#2280) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/check.yml | 4 ++-- .github/workflows/lint.yml | 4 ++-- .github/workflows/test.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index ed9651b025..84f6a9bf34 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: "3.11" cache: "pip" @@ -26,7 +26,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: "3.11" cache: "pip" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 35cb6d490d..44e5c35799 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: "3.11" cache: "pip" @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@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 9a2b03aa55..effb760e9f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: PYTHON: ${{ matrix.python-version }} steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} cache: "pip" @@ -50,7 +50,7 @@ jobs: steps: - 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" From 037e3edd25486a9bd2fd668886d13f2706e0ed51 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Dec 2023 09:01:55 +0000 Subject: [PATCH 18/33] chore(deps): update msgspec requirement from ~=0.18.4 to ~=0.18.5 (#2288) Updates the requirements on [msgspec](https://github.com/jcrist/msgspec) to permit the latest version. - [Release notes](https://github.com/jcrist/msgspec/releases) - [Commits](https://github.com/jcrist/msgspec/compare/0.18.4...0.18.5) --- updated-dependencies: - dependency-name: msgspec dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements/speed.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/speed.txt b/requirements/speed.txt index 5664d336cf..d4ce69e7e6 100644 --- a/requirements/speed.txt +++ b/requirements/speed.txt @@ -1,2 +1,2 @@ -msgspec~=0.18.4 +msgspec~=0.18.5 aiohttp[speedups] From 0da36ffe50fdd1fa0e76d0344201cd41932b5c12 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Dec 2023 09:10:59 +0000 Subject: [PATCH 19/33] chore(deps-dev): bump bandit from 1.7.5 to 1.7.6 (#2285) Bumps [bandit](https://github.com/PyCQA/bandit) from 1.7.5 to 1.7.6. - [Release notes](https://github.com/PyCQA/bandit/releases) - [Commits](https://github.com/PyCQA/bandit/compare/1.7.5...1.7.6) --- updated-dependencies: - dependency-name: bandit dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements/dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index 801aa1d698..1b59060097 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -7,5 +7,5 @@ mypy~=1.7.1 coverage~=7.3 pre-commit==3.5.0 codespell==2.2.6 -bandit==1.7.5 +bandit==1.7.6 flake8==6.1.0 From 213a1b6d2c504a81641ec9290fe9af91efc8a7bd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Dec 2023 09:27:30 +0000 Subject: [PATCH 20/33] chore(deps-dev): update pylint requirement from ~=3.0.2 to ~=3.0.3 (#2284) Updates the requirements on [pylint](https://github.com/pylint-dev/pylint) to permit the latest version. - [Release notes](https://github.com/pylint-dev/pylint/releases) - [Commits](https://github.com/pylint-dev/pylint/compare/v3.0.2...v3.0.3) --- updated-dependencies: - dependency-name: pylint dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements/dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index 1b59060097..3c71378e73 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,5 +1,5 @@ -r _.txt -pylint~=3.0.2 +pylint~=3.0.3 pytest~=7.4.3 pytest-asyncio~=0.23.2 # pytest-order~=1.0.1 From ca9700f9d94f4c88448699df922c1e63b17a5d62 Mon Sep 17 00:00:00 2001 From: Krutyi-4el <60041069+Krutyi-4el@users.noreply.github.com> Date: Thu, 14 Dec 2023 19:09:18 +0200 Subject: [PATCH 21/33] fix(ext.commands): required is False although default is None (#2282) --- discord/ext/commands/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index 4adb27cad0..c2282d28bf 100644 --- a/discord/ext/commands/core.py +++ b/discord/ext/commands/core.py @@ -565,7 +565,7 @@ async def dispatch_error(self, ctx: Context, error: Exception) -> None: async def transform(self, ctx: Context, param: inspect.Parameter) -> Any: if isinstance(param.annotation, Option): default = param.annotation.default - required = param.annotation.required or default is None + required = param.annotation.required else: default = param.default required = default is param.empty From 98c4e1954bd2c826618bbedb7f874d77bc3d6751 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Dec 2023 17:19:45 +0000 Subject: [PATCH 22/33] ci(deps): bump github/codeql-action from 2 to 3 (#2289) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/v2...v3) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Co-authored-by: plun1331 --- .github/workflows/codeql-analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 65da74cfb0..4fbb2b5b8a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -45,7 +45,7 @@ jobs: # 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 From c1a57fabb49901fdc455c2f11012d8100e90b147 Mon Sep 17 00:00:00 2001 From: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Date: Thu, 14 Dec 2023 20:29:55 +0300 Subject: [PATCH 23/33] fix: update typed dicts for commands (#2274) --- discord/bot.py | 4 ++-- discord/types/interactions.py | 32 +++++++++++++++++++++----------- 2 files changed, 23 insertions(+), 13 deletions(-) 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/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 From af97fea4256ade20bfa27a702bccb40a644130dc Mon Sep 17 00:00:00 2001 From: David Hozic Date: Thu, 14 Dec 2023 19:20:43 +0100 Subject: [PATCH 24/33] feat: ForumChannel default_reaction_emoji attribute (#2178) * ForumChannel default_reaction_emoji * style(pre-commit): auto fixes from pre-commit.com hooks * CHANGELOG.md * Changelog * style(pre-commit): auto fixes from pre-commit.com hooks * style(pre-commit): auto fixes from pre-commit.com hooks * .edit support * remove secret file * add missing type * style(pre-commit): auto fixes from pre-commit.com hooks * Fix formatting * Formatting * changelog.md * changelog formatting * changelog * style(pre-commit): auto fixes from pre-commit.com hooks * Update CHANGELOG.md Signed-off-by: Lala Sabathil --------- Signed-off-by: Lala Sabathil Signed-off-by: David Hozic Signed-off-by: plun1331 Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Lala Sabathil Co-authored-by: plun1331 --- CHANGELOG.md | 5 +++++ discord/abc.py | 23 +++++++++++++++++++++++ discord/channel.py | 25 +++++++++++++++++++++++-- discord/guild.py | 29 +++++++++++++++++++++++++++-- discord/http.py | 1 + discord/partial_emoji.py | 8 ++++---- 6 files changed, 83 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02294de6da..6928a6bac4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,11 @@ These changes are available on the `master` branch, but have not yet been releas ([#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 + `ForumChannel.edit()` methods. + ([#2178](https://github.com/Pycord-Development/pycord/pull/2178)) ### Changed diff --git a/discord/abc.py b/discord/abc.py index a7aba7ecc3..ce811492bc 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -50,6 +50,7 @@ from .invite import Invite from .iterators import HistoryIterator from .mentions import AllowedMentions +from .partial_emoji import PartialEmoji, _EmojiTag from .permissions import PermissionOverwrite, Permissions from .role import Role from .scheduled_events import ScheduledEvent @@ -507,6 +508,28 @@ async def _edit( raise InvalidArgument("type field must be of type ChannelType") options["type"] = ch_type.value + try: + default_reaction_emoji = options["default_reaction_emoji"] + except KeyError: + pass + else: + if isinstance(default_reaction_emoji, _EmojiTag): # Emoji, PartialEmoji + default_reaction_emoji = default_reaction_emoji._to_partial() + elif isinstance(default_reaction_emoji, int): + default_reaction_emoji = PartialEmoji( + name=None, id=default_reaction_emoji + ) + elif isinstance(default_reaction_emoji, str): + default_reaction_emoji = PartialEmoji.from_str(default_reaction_emoji) + else: + raise InvalidArgument( + "default_reaction_emoji must be of type: Emoji | int | str" + ) + + options[ + "default_reaction_emoji" + ] = default_reaction_emoji._to_forum_reaction_payload() + if options: return await self._state.http.edit_channel( self.id, reason=reason, **options diff --git a/discord/channel.py b/discord/channel.py index 5cd70f52f7..93925b29a9 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -32,6 +32,7 @@ from . import utils from .asset import Asset +from .emoji import Emoji from .enums import ( ChannelType, EmbeddedActivity, @@ -171,7 +172,7 @@ def to_dict(self) -> dict[str, Any]: payload: dict[str, Any] = { "name": self.name, "moderated": self.moderated, - } | self.emoji._to_forum_tag_payload() + } | self.emoji._to_forum_reaction_payload() if self.id: payload["id"] = self.id @@ -195,6 +196,7 @@ class _TextChannel(discord.abc.GuildChannel, Hashable): "last_message_id", "default_auto_archive_duration", "default_thread_slowmode_delay", + "default_reaction_emoji", "default_sort_order", "available_tags", "flags", @@ -228,7 +230,6 @@ def _update( self.name: str = data["name"] self.category_id: int | None = utils._get_as_snowflake(data, "parent_id") self._type: int = data["type"] - # This data may be missing depending on how this object is being created/updated if not data.pop("_invoke_flag", False): self.topic: str | None = data.get("topic") @@ -1008,6 +1009,10 @@ class ForumChannel(_TextChannel): The initial slowmode delay to set on newly created threads in this channel. .. versionadded:: 2.3 + default_reaction_emoji: Optional[:class:`str` | :class:`discord.Emoji`] + The default forum reaction emoji. + + .. versionadded:: 2.5 """ def __init__( @@ -1022,6 +1027,15 @@ def _update(self, guild: Guild, data: ForumChannelPayload) -> None: for tag in (data.get("available_tags") or []) ] self.default_sort_order: SortOrder | None = data.get("default_sort_order", None) + reaction_emoji_ctx: dict = data.get("default_reaction_emoji") + if reaction_emoji_ctx is not None: + emoji_name = reaction_emoji_ctx.get("emoji_name") + if emoji_name is not None: + self.default_reaction_emoji = reaction_emoji_ctx["emoji_name"] + else: + self.default_reaction_emoji = self._state.get_emoji( + utils._get_as_snowflake(reaction_emoji_ctx, "emoji_id") + ) @property def guidelines(self) -> str | None: @@ -1061,6 +1075,7 @@ async def edit( default_auto_archive_duration: ThreadArchiveDuration = ..., default_thread_slowmode_delay: int = ..., default_sort_order: SortOrder = ..., + default_reaction_emoji: Emoji | int | str | None = ..., available_tags: list[ForumTag] = ..., require_tag: bool = ..., overwrites: Mapping[Role | Member | Snowflake, PermissionOverwrite] = ..., @@ -1113,6 +1128,12 @@ async def edit(self, *, reason=None, **options): The default sort order type to use to order posts in this channel. .. versionadded:: 2.3 + default_reaction_emoji: Optional[:class:`discord.Emoji` | :class:`int` | :class:`str`] + The default reaction emoji. + Can be a unicode emoji or a custom emoji in the forms: + :class:`Emoji`, snowflake ID, string representation (eg. ''). + + .. versionadded:: 2.5 available_tags: List[:class:`ForumTag`] The set of tags that can be used in this channel. Must be less than `20`. diff --git a/discord/guild.py b/discord/guild.py index 2f449beb60..f2ef9aa8a0 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -47,7 +47,7 @@ from .channel import * from .channel import _guild_channel_factory, _threaded_guild_channel_factory from .colour import Colour -from .emoji import Emoji +from .emoji import Emoji, PartialEmoji, _EmojiTag from .enums import ( AuditLogAction, AutoModEventType, @@ -1395,6 +1395,7 @@ async def create_forum_channel( slowmode_delay: int = MISSING, nsfw: bool = MISSING, overwrites: dict[Role | Member, PermissionOverwrite] = MISSING, + default_reaction_emoji: Emoji | int | str = MISSING, ) -> ForumChannel: """|coro| @@ -1436,6 +1437,12 @@ async def create_forum_channel( To mark the channel as NSFW or not. reason: Optional[:class:`str`] The reason for creating this channel. Shows up on the audit log. + default_reaction_emoji: Optional[:class:`Emoji` | :class:`int` | :class:`str`] + The default reaction emoji. + Can be a unicode emoji or a custom emoji in the forms: + :class:`Emoji`, snowflake ID, string representation (eg. ''). + + .. versionadded:: v2.5 Returns ------- @@ -1449,7 +1456,7 @@ async def create_forum_channel( HTTPException Creating the channel failed. InvalidArgument - The permission overwrite information is not in proper form. + The argument is not in proper form. Examples -------- @@ -1485,6 +1492,24 @@ async def create_forum_channel( if nsfw is not MISSING: options["nsfw"] = nsfw + if default_reaction_emoji is not MISSING: + if isinstance(default_reaction_emoji, _EmojiTag): # Emoji, PartialEmoji + default_reaction_emoji = default_reaction_emoji._to_partial() + elif isinstance(default_reaction_emoji, int): + default_reaction_emoji = PartialEmoji( + name=None, id=default_reaction_emoji + ) + elif isinstance(default_reaction_emoji, str): + default_reaction_emoji = PartialEmoji.from_str(default_reaction_emoji) + else: + raise InvalidArgument( + "default_reaction_emoji must be of type: Emoji | int | str" + ) + + options[ + "default_reaction_emoji" + ] = default_reaction_emoji._to_forum_reaction_payload() + data = await self._create_channel( name, overwrites=overwrites, diff --git a/discord/http.py b/discord/http.py index 40d9ebd928..30184b665a 100644 --- a/discord/http.py +++ b/discord/http.py @@ -1096,6 +1096,7 @@ def create_channel( "rtc_region", "video_quality_mode", "auto_archive_duration", + "default_reaction_emoji", ) payload.update( {k: v for k, v in options.items() if k in valid_keys and v is not None} diff --git a/discord/partial_emoji.py b/discord/partial_emoji.py index ec5495c7af..171d6390c5 100644 --- a/discord/partial_emoji.py +++ b/discord/partial_emoji.py @@ -160,11 +160,11 @@ def to_dict(self) -> dict[str, Any]: def _to_partial(self) -> PartialEmoji: return self - def _to_forum_tag_payload( + def _to_forum_reaction_payload( self, - ) -> TypedDict("TagPayload", {"emoji_id": int, "emoji_name": None}) | TypedDict( - "TagPayload", {"emoji_id": None, "emoji_name": str} - ): + ) -> TypedDict( + "ReactionPayload", {"emoji_id": int, "emoji_name": None} + ) | TypedDict("ReactionPayload", {"emoji_id": None, "emoji_name": str}): if self.id is None: return {"emoji_id": None, "emoji_name": self.name} else: From 634938b3d13c502689d08fce653e4ea5f96ed36f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Dec 2023 01:30:38 +0000 Subject: [PATCH 25/33] chore(deps): bump sphinxext-opengraph from 0.9.0 to 0.9.1 (#2290) Bumps [sphinxext-opengraph](https://github.com/wpilibsuite/sphinxext-opengraph) from 0.9.0 to 0.9.1. - [Release notes](https://github.com/wpilibsuite/sphinxext-opengraph/releases) - [Commits](https://github.com/wpilibsuite/sphinxext-opengraph/compare/v0.9.0...v0.9.1) --- updated-dependencies: - dependency-name: sphinxext-opengraph dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements/docs.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/docs.txt b/requirements/docs.txt index 2c8cb6ede3..605916439c 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.9.0 +sphinxext-opengraph==0.9.1 sphinx-copybutton==0.5.2 furo@ git+https://github.com/pradyunsg/furo@193643f sphinx-autodoc-typehints==1.23.0 From 510a44bd7c952c34d1aa7c6b63e60dad001b7a88 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 15 Dec 2023 20:02:07 +0000 Subject: [PATCH 26/33] chore(pre-commit): pre-commit autoupdate (#2283) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e0cd7bbdfe..f35687365b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: - id: pyupgrade args: [--py38-plus] - repo: https://github.com/PyCQA/isort - rev: 5.12.0 + rev: 5.13.0 hooks: - id: isort - repo: https://github.com/psf/black @@ -77,7 +77,7 @@ repos: # - id: mypy - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.1.0 + rev: v4.0.0-alpha.4 hooks: - id: prettier args: [--prose-wrap=always, --print-width=88] From 87d3d8a218e83065019edfa85b676d3f8d0857e9 Mon Sep 17 00:00:00 2001 From: plun1331 Date: Mon, 18 Dec 2023 21:27:35 -0800 Subject: [PATCH 27/33] feat: support python 3.12 (#2292) * feat: upgrade setuptools for 3.12 * ci: target 3.12 --- .github/workflows/check.yml | 4 ++-- .github/workflows/lint.yml | 4 ++-- .github/workflows/test.yml | 2 +- pyproject.toml | 5 +++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 84f6a9bf34..8462f34514 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.12" cache: "pip" cache-dependency-path: "requirements/dev.txt" - name: Install dependencies @@ -28,7 +28,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.12" cache: "pip" cache-dependency-path: "requirements/dev.txt" - name: Install dependencies diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 44e5c35799..7a1908dea8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.12" cache: "pip" cache-dependency-path: "requirements/dev.txt" - name: Install dependencies @@ -34,7 +34,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.11" + python-version: "3.12" cache: "pip" cache-dependency-path: "requirements/dev.txt" - name: Install dependencies diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index effb760e9f..020847ffc1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] env: OS: ${{ matrix.os }} PYTHON: ${{ matrix.python-version }} diff --git a/pyproject.toml b/pyproject.toml index e58300e470..0f3af97474 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] requires = [ - "setuptools>=62.6,<66", + "setuptools>=62.6,<70", "setuptools-scm>=6.2,<8", ] build-backend = "setuptools.build_meta" @@ -24,6 +24,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Internet", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules", @@ -65,7 +66,7 @@ voice = {file = "requirements/voice.txt"} [tool.setuptools_scm] [tool.black] -target-version = ['py38', 'py39', 'py310', 'py311'] +target-version = ['py38', 'py39', 'py310', 'py311', 'py312'] [tool.isort] profile = "black" From 40d2b00b0289e8d55f98ec1c5c6ee95a3669205d Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Tue, 19 Dec 2023 06:57:15 +0100 Subject: [PATCH 28/33] fix: auditlogs after param for fetch is ignored (#2295) --- CHANGELOG.md | 2 ++ discord/iterators.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6928a6bac4..6ece1cf3d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -201,6 +201,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#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)) +- Fixed `AuditLogIterator` not respecting the `after` parameter. + ([#2295](https://github.com/Pycord-Development/pycord/issues/2295)) ## [2.4.1] - 2023-03-20 diff --git a/discord/iterators.py b/discord/iterators.py index b171d70ed6..7507cfd5d8 100644 --- a/discord/iterators.py +++ b/discord/iterators.py @@ -430,7 +430,7 @@ def __init__( self.before = before self.user_id = user_id self.action_type = action_type - self.after = OLDEST_OBJECT + self.after = after or OLDEST_OBJECT self._users = {} self._state = guild._state From 16c696cd9948b016b097e1c0b03c54a5bfc4b994 Mon Sep 17 00:00:00 2001 From: Om Lanke <92863779+OmLanke@users.noreply.github.com> Date: Fri, 22 Dec 2023 12:38:49 +0530 Subject: [PATCH 29/33] fix: handle ephemeral messages in `disable_on_timeout` (#2297) * attempt fix * style(pre-commit): auto fixes from pre-commit.com hooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- discord/ui/view.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/discord/ui/view.py b/discord/ui/view.py index 5bf96f2612..322371d080 100644 --- a/discord/ui/view.py +++ b/discord/ui/view.py @@ -368,7 +368,12 @@ async def on_timeout(self) -> None: """ if self.disable_on_timeout: self.disable_all_items() - message = self._message or self.parent + + if not self._message or self._message.flags.ephemeral: + message = self.parent + else: + message = self.message + if message: m = await message.edit(view=self) if m: From ff2037f41c48f7d7c358b75ab3285da835d74729 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Dec 2023 21:30:26 +0000 Subject: [PATCH 30/33] chore(deps-dev): update mypy requirement from ~=1.7.1 to ~=1.8.0 (#2296) Updates the requirements on [mypy](https://github.com/python/mypy) to permit the latest version. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v1.7.1...v1.8.0) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> --- requirements/dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index 3c71378e73..7e38c4a1ac 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -3,7 +3,7 @@ pylint~=3.0.3 pytest~=7.4.3 pytest-asyncio~=0.23.2 # pytest-order~=1.0.1 -mypy~=1.7.1 +mypy~=1.8.0 coverage~=7.3 pre-commit==3.5.0 codespell==2.2.6 From ec212e2af388c8dc974a9917ab793745a53c3352 Mon Sep 17 00:00:00 2001 From: Dasupergrasskakjd <106623583+Dasupergrasskakjd@users.noreply.github.com> Date: Wed, 27 Dec 2023 17:38:52 +0000 Subject: [PATCH 31/33] fix: `AttributeError` when failing to establish initial websocket connection. (#2301) * fix #2300 * Update CHANGELOG.md * style(pre-commit): auto fixes from pre-commit.com hooks * Update CHANGELOG.md * Update CHANGELOG.md Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> Signed-off-by: Dasupergrasskakjd <106623583+Dasupergrasskakjd@users.noreply.github.com> --------- Signed-off-by: Dasupergrasskakjd <106623583+Dasupergrasskakjd@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com> --- CHANGELOG.md | 2 ++ discord/client.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ece1cf3d2..e8878fadad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -203,6 +203,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#2257](https://github.com/Pycord-Development/pycord/issues/2257)) - Fixed `AuditLogIterator` not respecting the `after` parameter. ([#2295](https://github.com/Pycord-Development/pycord/issues/2295)) +- Fixed `AttributeError` when failing to establish initial websocket connection. + ([#2301](https://github.com/Pycord-Development/pycord/pull/2301)) ## [2.4.1] - 2023-03-20 diff --git a/discord/client.py b/discord/client.py index 5a025aa660..3144011967 100644 --- a/discord/client.py +++ b/discord/client.py @@ -653,6 +653,8 @@ async def connect(self, *, reconnect: bool = True) -> None: # Always try to RESUME the connection # If the connection is not RESUME-able then the gateway will invalidate the session. # This is apparently what the official Discord client does. + if self.ws is None: + continue ws_params.update( sequence=self.ws.sequence, resume=True, session=self.ws.session_id ) From 8af8454a5befbdd6589d24016dcc7bfee252de0b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 18:51:05 +0000 Subject: [PATCH 32/33] chore(deps-dev): update coverage requirement from ~=7.3 to ~=7.4 (#2305) Updates the requirements on [coverage](https://github.com/nedbat/coveragepy) to permit the latest version. - [Release notes](https://github.com/nedbat/coveragepy/releases) - [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst) - [Commits](https://github.com/nedbat/coveragepy/compare/7.3.0...7.4.0) --- updated-dependencies: - dependency-name: coverage dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements/dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index 7e38c4a1ac..4aede160f1 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -4,7 +4,7 @@ pytest~=7.4.3 pytest-asyncio~=0.23.2 # pytest-order~=1.0.1 mypy~=1.8.0 -coverage~=7.3 +coverage~=7.4 pre-commit==3.5.0 codespell==2.2.6 bandit==1.7.6 From fc7b1042c4a9a942b9996dfe96f56aac059e179c Mon Sep 17 00:00:00 2001 From: Dasupergrasskakjd <106623583+Dasupergrasskakjd@users.noreply.github.com> Date: Wed, 3 Jan 2024 16:53:06 +0000 Subject: [PATCH 33/33] fix: change default attribute of `SlashCommandGroup` (#2303) * Update core.py and changelog * Update core.py * Update core.py * Update core.py * chore: update changelog * fix: remove all references to cog being MISSING --------- Signed-off-by: Dasupergrasskakjd <106623583+Dasupergrasskakjd@users.noreply.github.com> Co-authored-by: Dorukyum --- CHANGELOG.md | 2 ++ discord/commands/core.py | 9 +++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8878fadad..fea137c75a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -205,6 +205,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#2295](https://github.com/Pycord-Development/pycord/issues/2295)) - Fixed `AttributeError` when failing to establish initial websocket connection. ([#2301](https://github.com/Pycord-Development/pycord/pull/2301)) +- Fixed `AttributeError` caused by `command.cog` being `MISSING`. + ([#2303](https://github.com/Pycord-Development/pycord/issues/2303)) ## [2.4.1] - 2023-03-20 diff --git a/discord/commands/core.py b/discord/commands/core.py index c7bd4efd40..aff52c8108 100644 --- a/discord/commands/core.py +++ b/discord/commands/core.py @@ -846,7 +846,7 @@ def _is_typing_annotated(self, annotation): @property def cog(self): - return getattr(self, "_cog", MISSING) + return getattr(self, "_cog", None) @cog.setter def cog(self, val): @@ -1162,7 +1162,7 @@ def __init__( self._before_invoke = None self._after_invoke = None - self.cog = MISSING + self.cog = None self.id = None # Permissions @@ -1238,10 +1238,7 @@ def to_dict(self) -> dict: return as_dict def add_command(self, command: SlashCommand) -> None: - # check if subcommand has no cog set - # also check if cog is MISSING because it - # might not have been set by the cog yet - if command.cog is MISSING and self.cog is not MISSING: + if command.cog is None and self.cog is not None: command.cog = self.cog self.subcommands.append(command)