Skip to content

Commit 4829614

Browse files
committed
♻️ Check also in ConnectionState
1 parent a2eb1f1 commit 4829614

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ These changes are available on the `master` branch, but have not yet been releas
9494
([#2176](https://github.com/Pycord-Development/pycord/pull/2176))
9595
- Updated `Guild.filesize_limit` to 10 MB instead of 25 MB following Discord's API
9696
changes. ([#2671](https://github.com/Pycord-Development/pycord/pull/2671))
97-
- Made `Client.intents` writable as long as the client wasn't started.
98-
([#2687](https://github.com/Pycord-Development/pycord/pull/2687))
97+
- Made `Client.intents` and `ConnectionState.intents` writable as long as the client
98+
wasn't started. ([#2687](https://github.com/Pycord-Development/pycord/pull/2687))
9999

100100
### Deprecated
101101

discord/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,9 @@ def intents(self, value: Any) -> None: # pyright: ignore [reportExplicitAny]
908908
f"Intents must be an instance of Intents not {value.__class__!r}"
909909
)
910910
if self._was_connected:
911-
raise ClientException("Cannot change intents on a running client.")
911+
raise AttributeError(
912+
"Cannot change intents after the connection is established."
913+
)
912914
self._connection.intents = value
913915

914916
# helpers/getters

discord/state.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,11 @@ def intents(self, value: Any) -> None: # pyright: ignore [reportExplicitAny]
352352
"""
353353
if not isinstance(value, Intents):
354354
raise TypeError(f"Intents must be of type Intents not {value.__class__!r}")
355+
ws = self._get_websocket()
356+
if ws and ws.open:
357+
raise AttributeError(
358+
"Cannot change intents after the connection is established."
359+
)
355360
self._intents.value = value.value
356361

357362
@property

0 commit comments

Comments
 (0)