mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-06 03:47:29 +00:00
Fix README example code.
This commit is contained in:
parent
ba3e00c3bf
commit
ca450fb0e4
@ -46,6 +46,7 @@ Note that this requires `git` to be installed.
|
|||||||
|
|
||||||
```py
|
```py
|
||||||
import discord
|
import discord
|
||||||
|
import asyncio
|
||||||
|
|
||||||
client = discord.Client()
|
client = discord.Client()
|
||||||
|
|
||||||
@ -76,8 +77,12 @@ def main_task():
|
|||||||
yield from client.connect()
|
yield from client.connect()
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
loop.run_until_complete(main_task())
|
try:
|
||||||
loop.close()
|
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.
|
You can find examples in the examples directory.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user