Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 448
Riju Avatar asked Jun 17 '26 07:06

Riju


2 Answers

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}!")
like image 194
Fixator10 Avatar answered Jun 23 '26 22:06

Fixator10


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

like image 30
mazi710 Avatar answered Jun 23 '26 21:06

mazi710