aboutsummaryrefslogtreecommitdiff
path: root/examples/edits.py
blob: 375a9bde3b7c863b2f4ec43f23513960348032b7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import discord
import asyncio

class MyClient(discord.Client):
    async def on_ready(self):
        print('Connected!')
        print(f'Username: {self.user.name}\nID: {self.user.id}')

    async def on_message(self, message):
        if message.content.startswith('!editme'):
            msg = await message.channel.send('10')
            await asyncio.sleep(3.0)
            await msg.edit(content='40')

    async def on_message_edit(self, before, after):
        msg = f'**{before.author}** edited their message:\n{before.content} -> {after.content}'
        await before.channel.send(msg)

client = MyClient()
client.run('token')