1
mstatus = True

for mem in members:
  memberreact = await mem.user.send("do you wish to approve  or decline?\nchoose ⬆️ to approve and ⬇️ to decline!!")

  await memberreact.add_reaction("⬆️")
  await memberreact.add_reaction("⬇️")

  def mcheck1(reaction, user):
    return user == mem.user and reaction.message.id == memberreact.id and str(reaction.emoji) == "⬆️"
  def mcheck2(reaction, user):
    return user == mem.user and reaction.message.id == memberreact.id and str(reaction.emoji) == "⬇️"

  async def mreact1(mstatus):
    #first logic
    if mstatus == True:
      reaction, user = await client.wait_for("reaction_add", check=mcheck1)
      await mem.user.send("you have approved!!")
      mstatus = False
      print(mstatus)
  async def mreact2(mstatus):
    #second logic
    if mstatus == True:
      reaction, user = await client.wait_for("reaction_add", check=mcheck2)
      await mem.user.send("you have decline!!")
      mstatus = False
      print(mstatus)
     
  await asyncio.gather(mreact1(mstatus), mreact2(mstatus))

这段代码在对⬆️做出反应时给了我第一个逻辑,在同一条消息中对⬇️做出反应时给了我第二个逻辑..但这没有意义,因为代码中的 mstatus 在第一次对⬆️做出反应时变为 False .. 有吗这段代码有什么问题吗?如果是,请告诉我..

4

1 回答 1

0

你打错了,很简单:

async def mreact1(mstatus):
   if mstatus == True:
      reaction, user = await client.wait_for("reaction_add", check=mcheck1)
      await mem.user.send("you have approved!!")
      mstatus = False ## SHOULD BE TRUE!!!!!
      print(mstatus)
于 2021-04-08T07:12:32.937 回答