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] 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 )