aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-01-09 21:25:03 -0500
committerRapptz <[email protected]>2017-01-09 21:25:03 -0500
commit3c6d677f85ac7ce119bf7185043f79b540c8a10f (patch)
treeb22527fb0136df962d2a8dc7dfeb29804350f87f
parentFix HTTP.application_info 404ing. (diff)
downloaddiscord.py-3c6d677f85ac7ce119bf7185043f79b540c8a10f.tar.xz
discord.py-3c6d677f85ac7ce119bf7185043f79b540c8a10f.zip
Update README example.
-rw-r--r--README.md45
1 files changed, 22 insertions, 23 deletions
diff --git a/README.md b/README.md
index fb324b86..4502770a 100644
--- a/README.md
+++ b/README.md
@@ -56,29 +56,28 @@ Please note that on Linux installing voice you must install the following packag
import discord
import asyncio
-client = discord.Client()
-
-async def on_ready():
- print('Logged in as')
- print(client.user.name)
- print(client.user.id)
- print('------')
-
-async def on_message(message):
- if message.content.startswith('!test'):
- counter = 0
- tmp = await client.send_message(message.channel, 'Calculating messages...')
- 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')
-
+class MyClient(discord.Client):
+ async def on_ready(self):
+ print('Logged in as')
+ print(self.user.name)
+ print(self.user.id)
+ print('------')
+
+ async def on_message(self, message):
+ if message.content.startswith('!test'):
+ counter = 0
+ tmp = await message.channel.send('Calculating messages...')
+ async for msg in message.channel.history(limit=100):
+ if msg.author == message.author:
+ counter += 1
+
+ await tmp.edit(content='You have {} messages.'.format(counter))
+ elif message.content.startswith('!sleep'):
+ with message.channel.typing():
+ await asyncio.sleep(5.0)
+ await message.channel.send('Done sleeping.')
+
+client = MyClient()
client.run('token')
```