[英]Discord.py-rewrite wait_for() how do i use?
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? 我不能真正按照我想要的方式使用
wait_if ()
,没有人可以解释仅由命令用户使用wait_for ('message')
和wait_for ('reaction')
的方法吗? (message translated by Google Translate, forgive me for any error...) (由Google翻译翻译的消息,如有任何错误,请原谅我...)
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. wait_for
带有一个check
参数,该参数是一个函数,该函数接受您正在等待的事件的参数,并确定是否是您正在等待的事件。
For example, the on_message
event takes a message
argument, so if we wanted to check the author of a message we could do: 例如,
on_message
事件采用message
参数,因此,如果我们要检查消息的作者,可以执行以下操作:
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!")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.