Skip to content

Commit

Permalink
♻️ Check also in ConnectionState
Browse files Browse the repository at this point in the history
  • Loading branch information
Paillat-dev committed Jan 7, 2025
1 parent a2eb1f1 commit 4829614
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2176](https://github.com/Pycord-Development/pycord/pull/2176))
- Updated `Guild.filesize_limit` to 10 MB instead of 25 MB following Discord's API
changes. ([#2671](https://github.com/Pycord-Development/pycord/pull/2671))
- Made `Client.intents` writable as long as the client wasn't started.
([#2687](https://github.com/Pycord-Development/pycord/pull/2687))
- Made `Client.intents` and `ConnectionState.intents` writable as long as the client
wasn't started. ([#2687](https://github.com/Pycord-Development/pycord/pull/2687))

### Deprecated

Expand Down
4 changes: 3 additions & 1 deletion discord/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,9 @@ def intents(self, value: Any) -> None: # pyright: ignore [reportExplicitAny]
f"Intents must be an instance of Intents not {value.__class__!r}"
)
if self._was_connected:
raise ClientException("Cannot change intents on a running client.")
raise AttributeError(
"Cannot change intents after the connection is established."
)
self._connection.intents = value

# helpers/getters
Expand Down
5 changes: 5 additions & 0 deletions discord/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ def intents(self, value: Any) -> None: # pyright: ignore [reportExplicitAny]
"""
if not isinstance(value, Intents):
raise TypeError(f"Intents must be of type Intents not {value.__class__!r}")
ws = self._get_websocket()
if ws and ws.open:
raise AttributeError(
"Cannot change intents after the connection is established."
)
self._intents.value = value.value

@property
Expand Down

0 comments on commit 4829614

Please sign in to comment.