Update example code.

This commit is contained in:
Rapptz
2015-12-06 03:05:50 -05:00
parent a91dad53a8
commit e87d54dd12
5 changed files with 32 additions and 33 deletions

View File

@ -1,24 +1,24 @@
import discord
import time
import asyncio
client = discord.Client()
client.login('email', 'password')
@client.event
@client.async_event
def on_ready():
print('Connected!')
print('Username: ' + client.user.name)
print('ID: ' + client.user.id)
@client.event
@client.async_event
def on_message(message):
if message.content.startswith('!editme'):
msg = client.send_message(message.author, '10')
time.sleep(3)
client.edit_message(msg, '40')
msg = yield from client.send_message(message.author, '10')
yield from asyncio.sleep(3)
yield from client.edit_message(msg, '40')
@client.event
@client.async_event
def on_message_edit(before, after):
client.send_message(after.channel, '**{}** edited their message:\n{}'.format(after.author.name, before.content))
fmt = '**{0.author}** edited their message:\n{1.content}'
yield from client.send_message(after.channel, fmt.format(after, before))
client.run()
client.run('email', 'password')