diff options
| author | pyxiis <[email protected]> | 2021-08-26 15:50:21 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-08-26 15:50:21 -0400 |
| commit | 2f2c39ed22506d21a84e86ad8cb4b4bed5c563be (patch) | |
| tree | c14a5ac68bdfb3a5a4b45c5b7e2e7a6c5a8cafb2 | |
| parent | Make arguments positional only in 2 get methods (diff) | |
| download | discord.py-2f2c39ed22506d21a84e86ad8cb4b4bed5c563be.tar.xz discord.py-2f2c39ed22506d21a84e86ad8cb4b4bed5c563be.zip | |
Add Client.status attribute
| -rw-r--r-- | discord/client.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/discord/client.py b/discord/client.py index 6c4a52ec..a9988f18 100644 --- a/discord/client.py +++ b/discord/client.py @@ -687,6 +687,26 @@ class Client: self._connection._activity = value.to_dict() # type: ignore else: raise TypeError('activity must derive from BaseActivity.') + + @property + def status(self): + """:class:`.Status`: + The status being used upon logging on to Discord. + + .. versionadded: 2.0 + """ + if self._connection._status in set(state.value for state in Status): + return Status(self._connection._status) + return Status.online + + @status.setter + def status(self, value): + if value is Status.offline: + self._connection._status = 'invisible' + elif isinstance(value, Status): + self._connection._status = str(value) + else: + raise TypeError('status must derive from Status.') @property def allowed_mentions(self) -> Optional[AllowedMentions]: |