How to receive a message from a certain user in discord, then wait for another certain user's reply, then send a custom message in python

Viewed 114

I'm new to python and discord bots. I created a bot for my friend's server and I'm stuck on a certain event. I want to be able to:

  1. Wait for a certain user to send a random message
  2. Wait for a certain user to respond to that message (if the someone else replies before the user I want, I want the code to stop running
  3. Have the bot send a message

Here's my code, it may be incorrect, but I have never done something like this before. I would love it if someone replied with the full event function. Thanks!

@client.event
async def on_message(message):
    if (message.author.id == "User who sends the first message"):   
            async def on_message(message):    
                if (message.author.id == "User who replies"):
                    await message.channel.send("Test worked")
                    print(on_message)
                else:
                    return
    else:
        return
1 Answers

there is an inbuilt function for that

def check(user):
  return user.channel.id == message.channel.id and user.author == message.author
reply = await bot.wait_for('message', check=check())
Related