Update README example.

This commit is contained in:
Rapptz 2017-01-09 21:25:03 -05:00
parent b86a568f86
commit 3c6d677f85

View File

@ -56,29 +56,28 @@ Please note that on Linux installing voice you must install the following packag
import discord import discord
import asyncio import asyncio
client = discord.Client() class MyClient(discord.Client):
async def on_ready(self):
print('Logged in as')
print(self.user.name)
print(self.user.id)
print('------')
@client.event async def on_message(self, message):
async def on_ready(): if message.content.startswith('!test'):
print('Logged in as') counter = 0
print(client.user.name) tmp = await message.channel.send('Calculating messages...')
print(client.user.id) async for msg in message.channel.history(limit=100):
print('------') if msg.author == message.author:
counter += 1
@client.event await tmp.edit(content='You have {} messages.'.format(counter))
async def on_message(message): elif message.content.startswith('!sleep'):
if message.content.startswith('!test'): with message.channel.typing():
counter = 0 await asyncio.sleep(5.0)
tmp = await client.send_message(message.channel, 'Calculating messages...') await message.channel.send('Done sleeping.')
async for log in client.logs_from(message.channel, limit=100):
if log.author == message.author:
counter += 1
await client.edit_message(tmp, 'You have {} messages.'.format(counter))
elif message.content.startswith('!sleep'):
await asyncio.sleep(5)
await client.send_message(message.channel, 'Done sleeping')
client = MyClient()
client.run('token') client.run('token')
``` ```