[英]How do I make my discord python bot recognize response in chat after command?
So in short.所以简而言之。 I want to made a regular command that makes the bot ask a question and gives an a,b,c answer.
我想发出一个常规命令,让机器人提出问题并给出 a,b,c 答案。 I want to make it look for the next message of the person that triggered the command and check the message and see if it's the correct answer.
我想让它查找触发命令的人的下一条消息并检查消息,看看它是否是正确的答案。
So I am guessing I have to use the code:所以我猜我必须使用代码:
@bot.listen()
async def on_message(message):
Do I compare the person who sent the message to the person the bot is expecting to answer and if so, where would I be best off storing that info?我是否将发送消息的人与机器人期望回答的人进行比较,如果是,我最好将这些信息存储在哪里?
You guessed wrong, you should use the bot.wait_for
method, example你猜错了,应该使用
bot.wait_for
方法,例子
@bot.command()
async def foo(ctx):
def check(message):
return message.author == ctx.author
await ctx.send("whatever")
message = await bot.wait_for("message", check=check)
await ctx.send(f"Thanks for the reply! Your message: {message.content}")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.