Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x Discord.py如何使某些内容仅在其他内容之后可用_Python 3.x_Bots_Discord.py_Accessibility - Fatal编程技术网

Python 3.x Discord.py如何使某些内容仅在其他内容之后可用

Python 3.x Discord.py如何使某些内容仅在其他内容之后可用,python-3.x,bots,discord.py,accessibility,Python 3.x,Bots,Discord.py,Accessibility,我想让是或否只有在您键入后才可访问!版本,你能告诉我怎么做吗?我想不出来。我的代码使得每次都可以访问Yes和No async def on_message(message): if message.content.startswith('!Version'): await message.channel.send('Sure?') if message.content.startswith('Yes'): await messag

我想让是或否只有在您键入后才可访问!版本,你能告诉我怎么做吗?我想不出来。我的代码使得每次都可以访问Yes和No

async def on_message(message):
    if message.content.startswith('!Version'):
        await message.channel.send('Sure?')     
    if message.content.startswith('Yes'):
            await message.channel.send('This is the Version 1.0')
    if message.content.startswith('No')
            await message.channel.send('Okay')  ```

最好不要使用消息事件,而是使用命令函数decorator,以便在命令运行后发送消息。相反,通过使用
wait\u for
,这将使您的bot实质上“等待”发送所需的消息。在您的情况下,在运行命令后,bot将等待“是”或“否”,以确定下一步可以发送什么

下面是一个示例,提示您的问题中有一个命令和
等待

@client.command()
异步def版本(ctx):
等待ctx。发送(f“确定?”)
msg=wait client.wait_for('message',timeout=10,check=lambda message:message.author==ctx.author)
如果msg.content.lower()=“是”:
等待ctx.send(“这是1.0版”)
如果msg.content.lower()=“否”:
等待ctx发送(“好”)

我怎样才能做到这一点!版本触发了这一点。对不起,我是编程新手