![](/img/trans.png)
[英]Discord.py: wait_for('reaction_add') not working as intended
[英]How can i use the wait_for(“reaction_add”) function only for a specific message? discord.py
就像機器人不會讀取消息的任何其他反應,而只會讀取特定消息。
將reaction.message == msgg
添加到此代碼中會有所幫助嗎? (我不知道 function 是否存在,我也測試過,但對我不起作用)
reaction, user = await client.wait_for("reaction_add")
if user == members.user and str(reaction.emoji) == "✔️":
await members.user.send("your answer is ✔️")
else:
return
您將檢查reaction.message.content
是否與您想要的消息相同。
reaction, user = await client.wait_for("reaction_add")
if reaction.message.content == "<desired message>":
if user == members.user and str(reaction.emoji) == "✔️":
await members.user.send("your answer is ✔️")
else:
return
您可以為此使用on_reaction_add
function,然后檢查用戶反應的消息是否是所需的消息。
@client.event
async def on_reaction_add(reaction, user):
if user.bot:
return
my_message_id = 1234567
if reaction.message.id == my_message_id
await message.channel.send("Your answer is ✔️")
else:
return
這適用於wait_for
Function 的check
參數:
reaction, user = await client.wait_for("reaction_add", check=lambda m: m.id == MESSAGE_ID)
if user == members.user and str(reaction.emoji) == "✔️":
await members.user.send("your answer is ✔️")
else:
return
(如果lambda m
和m.id
適用於反應,您將不得不對此進行測試)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.