Discord.py 让机器人等待回复 [英] Discord.py Make bot wait for reply

查看:22
本文介绍了Discord.py 让机器人等待回复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在我的机器人输入命令后等待作者回复的命令?谢谢

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

推荐答案

使用 Client.wait_for 等待 on_message 事件.

@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}!")

这篇关于Discord.py 让机器人等待回复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆