Riju
Riju

Reputation: 77

Discord.py Make bot wait for reply

How can I make a command in which my bot waits for a reply from the author after typing a command? Thanks

Upvotes: 2

Views: 15847

Answers (2)

mazi710
mazi710

Reputation: 41

What Fixator10 posted returned "Channel" is undefined for me. I changed it to "return m.content == "hello" and m.channel == ctx.channel" and it worked

Upvotes: 4

Fixator10
Fixator10

Reputation: 670

Use Client.wait_for to wait for on_message event.

@commands.command()
async def greet(ctx):
    await ctx.send("Say hello!")

    def check(m):
        return m.content == "hello" and m.channel == channel

    msg = await bot.wait_for("message", check=check)
    await ctx.send(f"Hello {msg.author}!")

Upvotes: 11

Related Questions