【发布时间】:2020-02-18 00:36:45
【问题描述】:
再次,我对编程很陌生,所以请耐心等待。我希望让我的机器人保存您所说的内容并稍后在消息中使用它。我遇到的问题是机器人正在保存应该提示它保存下一条消息的消息。
我尝试将不同的部分分成不同的 on_message 命令,但由于我使用全局布尔值来帮助机器人识别它应该在对话中的位置,因此,分离命令意味着机器人不依赖于 true /false 之前的 on_message 命令的分配。我还打算尝试将消息内容分配给不同的变量,以便机器人知道要保存哪条消息,但无法将这些变量合并到 await message.channel.send() 部分。
async def on_message(message):
global branch1
global branch2
if message.author == client.user:
return
if message.content.startswith("!ml"):
message.content = message.content.lower().replace(' ', '')
if message.content in command2 and not branch1:
branch1 = True
response2 = "Choose one or two"
await message.channel.send(response2)
if branch1:
if message.content in one and branch1:
branch1 = False
response3 = "yay"
await message.channel.send(response3)
branch2 = True
if branch2:
var1 = message.content
response4 = "hey " + var1
await message.channel.send(response4)
我希望机器人等到将 branch2 设置为 true 的命令之后才存储消息。相反,机器人会打印出:“yay”“hey!mlone”
【问题讨论】:
标签: python discord discord.py