Discord.py 让机器人等待回复
Discord.py Make bot wait for reply
如何创建一个命令,让我的机器人在输入命令后等待作者的回复?
谢谢
使用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}!")
Fixator10 发布的返回“频道”对我来说是未定义的。我将其更改为 "return m.content == "hello" and m.channel == ctx.channel"
并且有效
如何创建一个命令,让我的机器人在输入命令后等待作者的回复? 谢谢
使用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}!")
Fixator10 发布的返回“频道”对我来说是未定义的。我将其更改为 "return m.content == "hello" and m.channel == ctx.channel"
并且有效