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 .. 这段代码有什么问题吗?如果是,请告诉我..
答案 0 :(得分: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)