简体   繁体   中英

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. What I'm trying to make the bot do is that after the user type "$8ball" the bot will say "What's your question?" 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.

Try this. question will be what the user inputted. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM