1
0
mirror of https://github.com/Rapptz/discord.py.git synced 2025-05-16 02:39:01 +00:00

Add Client.start and Client.run shortcuts.

This commit is contained in:
Rapptz 2015-12-05 01:05:17 -05:00
parent 4287f85ba4
commit f755c970ab

@ -414,6 +414,28 @@ class Client:
self.keep_alive.cancel()
self._closed = True
@asyncio.coroutine
def start(self, email, password):
"""|coro|
A shorthand coroutine for :meth:`login` + :meth:`connect`.
"""
yield from self.login(email, password)
yield from self.connect()
def run(self, email, password):
"""A blocking call that abstracts away the `event loop`_
initialisation from you.
Equivalent to: ::
loop.run_until_complete(start(email, password))
loop.close()
"""
self.loop.run_until_complete(self.start(email, password))
self.loop.close()
# event registration
def event(self, coro):