diff options
| author | Rapptz <[email protected]> | 2017-01-03 20:57:41 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2017-01-03 20:58:11 -0500 |
| commit | f8a5d890fed1e2c7105964dfd1d310d6d7fa22ee (patch) | |
| tree | 73365f2e688746a029f1ae8293aa8eca965ffb11 /examples/reply.py | |
| parent | Fix Messageable.typing context manager. (diff) | |
| download | discord.py-f8a5d890fed1e2c7105964dfd1d310d6d7fa22ee.tar.xz discord.py-f8a5d890fed1e2c7105964dfd1d310d6d7fa22ee.zip | |
Update examples to match the new rewrite API.
Diffstat (limited to 'examples/reply.py')
| -rw-r--r-- | examples/reply.py | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/examples/reply.py b/examples/reply.py index 0413724c..c8f903f8 100644 --- a/examples/reply.py +++ b/examples/reply.py @@ -1,22 +1,19 @@ import discord -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('------') -async def on_message(message): - # we do not want the bot to reply to itself - if message.author == client.user: - return + async def on_message(self, message): + # we do not want the bot to reply to itself + if message.author.id == self.user.id: + return - if message.content.startswith('!hello'): - msg = 'Hello {0.author.mention}'.format(message) - await client.send_message(message.channel, msg) - -async def on_ready(): - print('Logged in as') - print(client.user.name) - print(client.user.id) - print('------') + if message.content.startswith('!hello'): + await message.channel.send('Hello {0.author.mention}'.format(message)) +client = MyClient() client.run('token') |