简体   繁体   English

我试图让我的 discord 机器人等待用户在执行原始命令后发送另一条消息

[英]I'm trying to get my discord bot to wait for the user to send another message after they did the original command

Sorry if the title didn't make sense, I'm making a discord bot and I'm trying to make a little 8 ball command.抱歉,如果标题没有意义,我正在制作一个 discord 机器人,我正在尝试制作一个小的 8 球命令。 What I'm trying to make the bot do is that after the user type "$8ball" the bot will say "What's your question?"我想让机器人做的是,在用户输入“$8ball”后,机器人会说“你有什么问题?” Then wait for the user to type out their question and then respond with the array of responses I've made for it.然后等待用户输入他们的问题,然后用我为它做出的一系列响应进行响应。

@client.event
async def on_message(message):
if message.author == client.user:
   return

if message.content.startswith("$8Ball"):
   await message.channel.send("What is your question?")

(that's all the code I have so far) (这就是我到目前为止的所有代码)

You can try to store the id of the user and react to the next message of this user.您可以尝试存储用户的 ID 并对该用户的下一条消息做出反应。

Try this.尝试这个。 question will be what the user inputted. question将是用户输入的内容。 It waits for a message in the same channel as the orginal command and by the same user who did the command它在与原始命令相同的频道中等待一条消息,并且来自执行该命令的同一用户

@client.event
async def on_message(message, author):
    if message.content.startswith('$8Ball'):
        channel = message.channel
        author = message.author
        await channel.send('What is your question?')

        def check(m):
            return m.author == author and m.channel == channel

        msg = await client.wait_for('message', check=check)
        question = msg.content

Tell me how it goes:D告诉我进展如何:D

暂无
暂无

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

相关问题 Discord Bot Python。我试图让我的机器人看到来自用户的命令,然后获取下一条消息内容(永远是机器人) - Discord Bot Python. I'm trying to get my bot to see a command from a user, then take the next message content (will always be a bot) 如何让我的 Discord Bot 使用他们的用户 ID 向另一个用户发送私人消息,我尝试了以下操作,但没有成功 - How Do I get my Discord Bot to Send a private message to another user using their user ID,I tried the following but it did not work 如何向执行 discord 机器人命令的用户发送直接消息? - How can i send a direct message to a user that executed a command to my discord bot? 我正在尝试让用户回复机器人响应,然后发送另一条消息 - I'm trying to make a user reply to a bot response then send another message 我在 python 中按下反应后,如何让我的 discord 机器人发送消息? - How can i get my discord bot to send a message after i press a reaction in python? 在我的discord机器人键入特定命令后,如何获得所有用户输入的字符串? - How do I get all user input as a string with my discord bot after they type a certain command? discord py - 如果用户回复我的机器人,则发送不同的消息 - discord py - Send a different message if a user replies to my bot 如何让我的 Discord Bot 在每次用户输入“验证”时发送一条消息 - How can I make my Discord Bot send a message every-time a user types 'verify' 我正在尝试用python写一个discord bot,但是我的代码不起作用 - I'm trying to write a discord bot in python but my code is not working discord.py 如何让机器人在特定用户类型时发送消息? - discord.py how do I get a bot to send a message when a specific user types?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM