siamese
siamese

Reputation: 17

"client.wait_for" function to work only with author

i'm making a car economy bot and I am currently programming the dealership I have used the function msg = await client.wait_for('message',timeout = 100.0, check=lambda message: not message.author.bot) to see what the user reply's with either 'Y' or 'N' , the problem is once the author types the command other people can also reply and the bot doesn't take the authors reply.

Basically I need to use msg = await client.wait_for('message',timeout = 100.0, check=lambda message: not message.author.bot) but it should only work with the author and ignore other peoples reply.

Upvotes: 0

Views: 107

Answers (1)

Mihito
Mihito

Reputation: 155

Use the author attribute from ctx object from the command.

@client.command()
async def foo(ctx):

    def check(message):
        return ctx.author.id == message.author.id

    msg = await client.wait_for("message",timeout = 100.0 ,check=check)

Of course you can do the same thing in a lambda funktion but in my opinion this is more readable.

Upvotes: 2

Related Questions