aboutsummaryrefslogtreecommitdiff
path: root/discord/client.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-09-18 05:46:51 -0400
committerRapptz <[email protected]>2017-09-18 05:46:51 -0400
commit025136076a02d4027e7fb227c6bdd3deefe16fbd (patch)
tree9dcb31cd1534704c1d82aefdf528e203c716c749 /discord/client.py
parentChange how coroutines are detected internally. (diff)
downloaddiscord.py-025136076a02d4027e7fb227c6bdd3deefe16fbd.tar.xz
discord.py-025136076a02d4027e7fb227c6bdd3deefe16fbd.zip
Add an example for on_reaction_add waiting.
Apparently people would rather read examples than the actual documentation.
Diffstat (limited to 'discord/client.py')
-rw-r--r--discord/client.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/discord/client.py b/discord/client.py
index 67d1fb9e..9000e27d 100644
--- a/discord/client.py
+++ b/discord/client.py
@@ -682,6 +682,25 @@ class Client:
msg = await client.wait_for('message', check=check)
await channel.send('Hello {.author}!'.format(msg))
+ Waiting for a thumbs up reaction from the message author: ::
+
+ @client.event
+ async def on_message(message):
+ if message.content.startswith('$thumb'):
+ channel = message.channel
+ await channel.send('Send me that \N{THUMBS UP SIGN} reaction, mate')
+
+ def check(reaction, user):
+ return user == message.author and str(reaction.emoji) == '\N{THUMBS UP SIGN}'
+
+ try:
+ reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check)
+ except asyncio.TimeoutError:
+ await channel.send('\N{THUMBS DOWN SIGN}')
+ else:
+ await channel.send('\N{THUMBS UP SIGN}')
+
+
Parameters
------------
event: str