如何在 discord.py 中再次接收来自聊天的输入?

How to recieve input from chat again in discord.py?

@client.event
async def on_message(message):
    print(message.author.bot)
    content = message.content
    author = message.author
    print("{}: {}".format(author, content))

    if message.content.startswith(".play"):
        import random
        words = [
            "expert",
            "error",
            "fairies",
            "star",
            "example",
            "pencil",
            "friction",
            "attraction",
            "horse",
            "vegetable",
            "stove",
            "invention"]
        word = random.choice(words)
        guesses = 7
        hint = ""
        i = 0
        try:
            await message.channel.send("Guess the word!")
            while guesses > 0:
                user_input = await client.wait_for('message', timeout=60.0, check=None)
                user_input = message.content
                print(user_input)
                if user_input == word:
                    await message.channel.send("You found the word!")
                elif user_input != word:
                    await message.channel.send("Guessed wrong!")
                    try:
                        hint += word[i]
                    except IndexError:
                        break
                    i += 1
                    await message.channel.send(f"Here is hint {hint}")
                    guesses -= 1
                    await message.channel.send(f"{guesses} left")
                if guesses == 0:
                    break
        except asyncio.TimeoutError:
            await message.channel.send("Time out!")

我尝试使用 python 将我的猜谜游戏集成到 discord 机器人中,但它是这样进行的:

** __0#1885: .play

#8974:猜单词!

__0#1885: 测试

#8974:猜错了!

#8974:这是提示 e

#8974: 还剩 6 个

__0#1885:专家

#8974:猜错了!

#8974:这是提示 ex

#8974: 还剩 5 个

__0#1885:额外

#8974:猜错了!

#8974:这是提示 exa

#8974: 还剩 4 个

__0#1885:例子

#8974:猜错了!

#8974:这是提示考试

#8974: 还剩 3 个

__0#1885:asd

#8974:猜错了!

#8974:这是提示示例

#8974: 还剩 2 个

** 如您所见,消息停留在“.play”。 (我调试过)问题是我不知道如何重置消息并接收另一个输入。

你的问题写的真烂。但是,如果您要搜索的是如何在此处获取用户输入,那么您应该怎么做。

import asyncio

@bot.command()
async def some_command(ctx):
    def check(message): # ALL FILTERS GO HERE
        return message.author.id == ctx.author.id and message.channel.id == ctx.channel.id
    
    try:
        message = await bot.wait_for('message', check=check, timeout=60.0)
    except asyncio.TimeoutError:
        await ctx.send('timeout')
        return
    await ctx.send("Text inputted: "+message.content)