【发布时间】:2019-04-07 06:06:15
【问题描述】:
我正在尝试设置 Discord 机器人,同时对 discord.py(实际上是 Python 3)相对较新。我想添加命令“greet”,它会提示用户对它说“hello”。但是,当我希望它同时响应“hello”和“Hello”时,它只会响应“hello”。
我唯一能想到的解决办法就是将它们放在 or 语句中,理论上这应该让 Python 3 和机器人在两个响应之间进行选择(如下所示)。
@client.event
async def on_message(message):
if message.content.startswith('~greet'):
await client.send_message(message.channel, 'Say hello')
msg = await client.wait_for_message(author=message.author, content=('hello' or 'Hello'))
await client.send_message(message.channel, 'Hello.')
我的原始代码很简单,只允许hello 的一个响应。
@client.event
async def on_message(message):
if message.content.startswith('~greet'):
await client.send_message(message.channel, 'Say hello')
msg = await client.wait_for_message(author=message.author, content=('hello' or 'Hello'))
await client.send_message(message.channel, 'Hello.')
由于某种原因,我无法绕开我的脑袋,它仍然无法识别 'Hello',并且只允许我说 'hello' 作为回应。
【问题讨论】:
-
这是重写还是异步分支?
标签: python-3.6 discord.py