简体   繁体   English

如何让我的 discord python 机器人在命令后识别聊天中的响应?

[英]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}")

Reference:参考:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何让我的 discord 机器人在聊天中显示“机器人正在打字” - How do i make my discord bot shows in chat like “Bot is typing” 如何为 Heroku 上的 Discord 机器人执行 Python 重新加载命令? - How do I make a Python reload command for the Discord bot on Heroku? 如何让我的 discord 机器人读取 Python 中的 dms? - How do I make my discord bot reading dms in Python? "如何在 Python 中为我的不和谐机器人制作购买功能?" - How do I make the buy function for my discord bot in Python? 如何随机回复我的 discord 机器人(在 python 中) - How do I make a random reply for my discord bot (in python) 如何让来自 discord.py 的机器人在我的语音聊天中播放音乐? - How do i make a bot from discord.py play music in my voice chat? 在 Python 中编程 Discord 机器人 - 当消息仅包含一个字母时,如何让它识别? - Programming a Discord bot in Python- How do I make it recognize when a message contains only one letter? 如何让我的 discord 机器人从文件中读取并将其粘贴到 discord 聊天命令中? - How to make my discord bot read from a file and paste it in a discord chat on command? 我如何制作使我的机器人离开服务器的命令(discord.py) - How do i make a command that make my bot leave from the server (discord.py) 如何让我的机器人的 Slash 响应检测 discord.py 中的反应? - How do I make my bot's Slash response detect reactions in discord.py?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM