diff options
| author | Rapptz <[email protected]> | 2017-12-16 21:36:39 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2017-12-16 21:36:39 -0500 |
| commit | 5c5a59c18e41538bee44ed85b7cf1806e830623d (patch) | |
| tree | 42a29138793346c93df4c8d0d97214619dc4a0ea /discord/client.py | |
| parent | Update README to point to new server. (diff) | |
| download | discord.py-5c5a59c18e41538bee44ed85b7cf1806e830623d.tar.xz discord.py-5c5a59c18e41538bee44ed85b7cf1806e830623d.zip | |
Add Client.clear to clear the bot's internal state to a clean slate.
In case you want to have some external restart loop.
Diffstat (limited to 'discord/client.py')
| -rw-r--r-- | discord/client.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/discord/client.py b/discord/client.py index deede9cc..1bc06d90 100644 --- a/discord/client.py +++ b/discord/client.py @@ -462,6 +462,18 @@ class Client: yield from self.http.close() self._ready.clear() + def clear(self): + """Clears the internal state of the bot. + + After this, the bot can be considered "re-opened", i.e. :meth:`.is_closed` + and :meth:`.is_ready` both return ``False`` along with the bot's internal + cache cleared. + """ + self._closed.clear() + self._ready.clear() + self._connection.clear() + self._http.recreate() + @asyncio.coroutine def start(self, *args, **kwargs): """|coro| |