Add client.setup and move readying commands to that

This commit is contained in:
Gnome
2021-08-31 19:13:32 +01:00
parent 7c83c335d1
commit 2cdf4b86c5
2 changed files with 31 additions and 13 deletions

View File

@@ -595,7 +595,7 @@ class Client:
async def start(self, token: str, *, reconnect: bool = True) -> None:
"""|coro|
A shorthand coroutine for :meth:`login` + :meth:`connect`.
A shorthand coroutine for :meth:`login` + :meth:`setup` + :meth:`connect`.
Raises
-------
@@ -603,8 +603,19 @@ class Client:
An unexpected keyword argument was received.
"""
await self.login(token)
await self.setup()
await self.connect(reconnect=reconnect)
async def setup(self) -> Any:
"""|coro|
A coroutine to be called to setup the bot, by default this is blank.
To perform asynchronous setup after the bot is logged in but before
it has connected to the Websocket, overwrite this coroutine.
"""
pass
def run(self, *args: Any, **kwargs: Any) -> None:
"""A blocking call that abstracts away the event loop
initialisation from you.