Python – Can wait_for_message check more than one thing?

Can wait_for_message check more than one thing?… here is a solution to the problem.

Can wait_for_message check more than one thing?

I’m waiting for news like this:

msg = await bot.wait_for_message(author=message.author, content = '.hit')

What I want to do though is wait for a message and then work on two different things, for example:

msg = await bot.wait_for_message(author=message.author, content = '.hit' or '.pass')

While this doesn’t

throw any errors, it doesn’t work. I checked:

if msg.content == (".hit"):

print("He hits.")

elif msg.content == (".pass"):

print("He passes.")

else:

print("It did not work.")

Does anyone know if this is feasible? Thanks!

Solution

You can do this:

msg = (await bot.wait_for("message")).content
    if msg == ".hit":
        print("He hits!")
    elif msg == ".pass":
        print("He passes!")
    else:
        print("He doesn't do anything")

Related Problems and Solutions