I can not really use wait_if ()
the way I want it, can anyone explain how to use wait_for ('message')
and wait_for ('reaction')
, only by the user of the command? (message translated by Google Translate, forgive me for any error...)
Asked
Active
Viewed 2.5k times
8

Patrick Haugh
- 59,226
- 13
- 88
- 96

Shiba Luck
- 105
- 2
- 2
- 4
1 Answers
9
wait_for
takes a check
argument that is a function that takes the arguments of the event you're waiting for and determines whether or not that is the event you're waiting for.
For example, the on_message
event takes a message
argument, so if we wanted to check the author of a message we could do:
msg = await client.wait_for('message', check=lambda message: message.author == ctx.author)
to see that the new message comes from the same person who invoked the currently running command.
If we wanted to send a message to the next person to react with a certain emoji, we could do
reaction, user = await client.wait_for('reaction_add',
check=lambda reaction, user: reaction.emoji == '')
await user.send(" to you too!")

sherpya
- 4,890
- 2
- 34
- 50

Patrick Haugh
- 59,226
- 13
- 88
- 96