Browse Source

Update README to use Python 3.5.

pull/77/head
Rapptz 9 years ago
parent
commit
85ceeb5efc
  1. 34
      README.md

34
README.md

@ -50,41 +50,33 @@ import asyncio
client = discord.Client() client = discord.Client()
@client.async_event @client.event
def on_ready(): async def on_ready():
print('Logged in as') print('Logged in as')
print(client.user.name) print(client.user.name)
print(client.user.id) print(client.user.id)
print('------') print('------')
@client.async_event @client.event
def on_message(message): async def on_message(message):
if message.content.startswith('!test'): if message.content.startswith('!test'):
logs = yield from client.logs_from(message.channel, limit=100) logs = await client.logs_from(message.channel, limit=100)
counter = 0 counter = 0
tmp = yield from client.send_message(message.channel, 'Calculating messages...') tmp = await client.send_message(message.channel, 'Calculating messages...')
for log in logs: for log in logs:
if log.author == message.author: if log.author == message.author:
counter += 1 counter += 1
yield from client.edit_message(tmp, 'You have {} messages.'.format(counter)) await client.edit_message(tmp, 'You have {} messages.'.format(counter))
elif message.content.startswith('!sleep'): elif message.content.startswith('!sleep'):
yield from asyncio.sleep(5) await asyncio.sleep(5)
yield from client.send_message(message.channel, 'Done sleeping') await client.send_message(message.channel, 'Done sleeping')
def main_task(): client.run('email', 'password')
yield from client.login('email', 'password')
yield from client.connect()
loop = asyncio.get_event_loop()
try:
loop.run_until_complete(main_task())
except Exception:
loop.run_until_complete(client.close())
finally:
loop.close()
``` ```
Note that in Python 3.4 you use `@asyncio.coroutine` instead of `async def` and `yield from` instead of `await`.
You can find examples in the examples directory. You can find examples in the examples directory.
## Requirements ## Requirements

Loading…
Cancel
Save