diff options
| author | Rapptz <[email protected]> | 2015-12-20 01:47:02 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2015-12-20 01:47:02 -0500 |
| commit | ca450fb0e44fc303a2c319e2fe53920714d7551e (patch) | |
| tree | 9feb51b823e6a1f95793200689e5d766183b654a | |
| parent | Add guessing game example to showcase wait_for_message. (diff) | |
| download | discord.py-ca450fb0e44fc303a2c319e2fe53920714d7551e.tar.xz discord.py-ca450fb0e44fc303a2c319e2fe53920714d7551e.zip | |
Fix README example code.
| -rw-r--r-- | README.md | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -46,6 +46,7 @@ Note that this requires `git` to be installed. ```py import discord +import asyncio client = discord.Client() @@ -76,8 +77,12 @@ def main_task(): yield from client.connect() loop = asyncio.get_event_loop() -loop.run_until_complete(main_task()) -loop.close() +try: + loop.run_until_complete(main_task()) +except Exception: + loop.run_until_complete(client.close()) +finally: + loop.close() ``` You can find examples in the examples directory. |