【发布时间】:2021-03-16 19:13:02
【问题描述】:
我创建了一个事件,如果用户发送特定消息,则返回消息。 前。如果用户说“你好”,机器人会说“你好”。我发现在下面的代码中,第一个 elif 有一个 or..so 如果用户说 ddos 或 hack,它会进入无限循环并继续发送 你不能这么说!。如果用户输入你好,机器人发送一次你好,然后进入无限循环并发送你不能这么说!。任何想法为什么?
@client.event
async def on_message(message):
msg = message.content.lower()
if str(msg) == "hello":
await message.channel.send('hello there')
elif str(msg) == "hack" or "ddos":
await message.channel.send("you can't say that!")
else:
return
【问题讨论】:
标签: discord.py