0
votes

I'm looking to make a command where if the message.author tags a user, the bot will react twice to the message then will wait for the user who was tagged to select either one or the other reaction to choose. Right now everything works except when the user reacts to one or the other emoji, it doesn't do anything. When they react to both emojis, it sends the message for reaction.

if message.content.lower().startswith('!marry'):
    user = message.mentions[0]
    if message.author == user:
        await client.send_message(message.channel, "{} you can't marry yourself dummy ????".format(message.author.mention))             
    else:
        if get_spouse(message.author) != "No One":
            await client.send_message(message.channel, "{}, you're already married to {} ????".format(message.author.mention, get_spouse(message.author)))
        else:
            if (get_spouse(user)) != "No One":
                await client.send_message(message.channel, "{} is already married. Get your own spouse. ????".format(user.mention))
            else:
                marriagemsg = await client.send_message(message.channel, "{} *has proposed to* {} ????".format(message.author.mention, user.mention))
                await client.add_reaction(marriagemsg, "✅")
                await client.add_reaction(marriagemsg, "❌")
                while True:
                    reaction = await client.wait_for_reaction(emoji="✅", message=marriagemsg, 
                                        check=lambda reaction, user: user == message.mentions[0])
                    reaction2 = await client.wait_for_reaction(emoji="❌", message=marriagemsg, 
                                        check=lambda reaction, user: user == message.mentions[0])
                    if reaction:
                        await client.send_message(message.channel, "{} **is now married to** {} ????????".format(message.author.mention, reaction.user.mention))
                        add_spouse(message.author, user.name)
                        add_spouse(reaction.user, message.author.name)
                    else:
                        if reaction2:
                            await client.send_message(message.channel, "{} **rejects** {}**'s proposal** ✋????".format(reaction2.user.mention, message.author.mention)) 
1

1 Answers

2
votes

The multiple wait_for_reaction checks that you are using is causing this. The bot will wait until the user reacts with ✅ on marriagemsg and only then check if the user reacts with ❌.

Instead of using multiple wait_for_reaction checks, just use one and populate your emojis in a list. You can also use elif instead of else: if.

if message.content.lower().startswith('!marry'):
    user = message.mentions[0]
    if message.author == user:
        await client.send_message(message.channel, "{} you can't marry yourself dummy 😒".format(message.author.mention))             
    else:
        if get_spouse(message.author) != "No One":
            await client.send_message(message.channel, "{}, you're already married to {} 😒".format(message.author.mention, get_spouse(message.author)))
        else:
            if (get_spouse(user)) != "No One":
                await client.send_message(message.channel, "{} is already married. Get your own spouse. 😒".format(user.mention))
            else:
                marriagemsg = await client.send_message(message.channel, "{} *has proposed to* {} 💍".format(message.author.mention, user.mention))
                await client.add_reaction(marriagemsg, "✅")
                await client.add_reaction(marriagemsg, "❌")
                answer = await client.wait_for_reaction(emoji=["✅", "❌"], message=marriagemsg, 
                                        check=lambda reaction, user: user == message.mentions[0])

                if answer.reaction.emoji == "✅":
                    await client.send_message(message.channel, "{} **is now married to** {} 🤵👰".format(message.author.mention, answer.user.mention))
                    add_spouse(message.author, user.name)
                    add_spouse(answer.user, message.author.name)
                elif answer.reaction.emoji == "❌":
                    await client.send_message(message.channel, "{} **rejects** {}**'s proposal** ✋🙄".format(answer.user.mention, message.author.mention))