From 2f2c39ed22506d21a84e86ad8cb4b4bed5c563be Mon Sep 17 00:00:00 2001 From: pyxiis Date: Thu, 26 Aug 2021 15:50:21 -0400 Subject: [PATCH] Add Client.status attribute --- discord/client.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/discord/client.py b/discord/client.py index 6c4a52ec0..a9988f182 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]: