diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7a1908dea8..d7238f4c3c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,7 +21,7 @@ jobs: pip install -r requirements/dev.txt - name: Setup cache id: cache-pylint - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: .pylint.d key: pylint @@ -43,7 +43,7 @@ jobs: pip install -r requirements/dev.txt - name: Setup cache id: cache-mypy - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: .mypy_cache key: mypy diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 020847ffc1..aa77843552 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,7 +35,7 @@ jobs: pip install -r requirements/dev.txt - name: Setup cache id: cache-pytest - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: .pytest_cache key: ${{ matrix.os }}-${{ matrix.python-version }}-pytest diff --git a/CHANGELOG.md b/CHANGELOG.md index 6928a6bac4..fea137c75a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -201,6 +201,12 @@ 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)) +- 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/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 ) 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) 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 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: diff --git a/discord/voice_client.py b/discord/voice_client.py index 437311122a..61bc0ad9d2 100644 --- a/discord/voice_client.py +++ b/discord/voice_client.py @@ -46,7 +46,7 @@ import struct import threading import time -from typing import TYPE_CHECKING, Any, Callable +from typing import TYPE_CHECKING, Any, Callable, Literal, overload from . import opus, utils from .backoff import ExponentialBackoff @@ -623,13 +623,33 @@ def get_ssrc(self, user_id): user_id ] + @overload def play( self, source: AudioSource, *, - after: Callable[[Exception | None], Any] = None, - wait_finish: bool = False, + after: Callable[[Exception | None], Any] | None = None, + wait_finish: Literal[False] = False, ) -> None: + ... + + @overload + def play( + self, + source: AudioSource, + *, + after: Callable[[Exception | None], Any] | None = None, + wait_finish: Literal[True], + ) -> asyncio.Future: + ... + + def play( + self, + source: AudioSource, + *, + after: Callable[[Exception | None], Any] | None = None, + wait_finish: bool = False, + ) -> None | asyncio.Future: """Plays an :class:`AudioSource`. The finalizer, ``after`` is called after the source has been exhausted diff --git a/requirements/dev.txt b/requirements/dev.txt index 3c71378e73..537bfcd6fc 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,11 +1,11 @@ -r _.txt pylint~=3.0.3 -pytest~=7.4.3 -pytest-asyncio~=0.23.2 +pytest~=7.4.4 +pytest-asyncio~=0.23.3 # pytest-order~=1.0.1 -mypy~=1.7.1 -coverage~=7.3 +mypy~=1.8.0 +coverage~=7.4 pre-commit==3.5.0 codespell==2.2.6 bandit==1.7.6 -flake8==6.1.0 +flake8==7.0.0