【发布时间】:2021-10-06 21:30:24
【问题描述】:
我最近开始制作不和谐机器人。所以我有这个不和谐的机器人,它的功能是问用户一个你想问的问题。因此,机器人从问题列表中获取一个问题并发送一条消息,要求用户选择第一个或第二个选项。此外,我希望机器人能够回应用户的回应,比如“不错的选择”。但是,它不起作用并且给了我错误。这样做的正确方法是什么?
这是我的代码:
# Event registered when bot recieves a message
@Client.event
async def on_message(message):
# Don't do anything if the message is from the bot
if message.author == Client.user:
return
if message.content.startswith("$Hi"):
await message.channel.send("Hello")
# WOULD YOU RATHER GAME COMMANDS
if message.content.startswith("$WYRG"):
await message.channel.send(random.choice(ListOfWYRGQuestions) + "\n\n Please enter 1 or 2 for option 1 or option 2.")
if message.content.startswith("1"):
await message.channel.send("Good choice!")
elif message.content.startswith("2"):
await message.channel.send("Good Choice!")
什么是更准确和正确的方式来响应用户的响应?
【问题讨论】:
标签: python python-3.x asynchronous discord discord.py