作为参考,我对python很陌生,所以我知道的不多。我正在为我正在处理的不和谐机器人创建一个非常简单的 madlibs 游戏。我让它提出问题,将用户响应放到一个变量上,提出另一个问题等。最后,它使用用户响应打印出“故事”。我的问题是,机器人不会写出消息的实际内容,而是写出所有消息的详细信息,例如用户 ID、频道 ID 等等。
@client.event
async def on_message(message):
if "madlibs" in message.content:
await message.channel.send("what dog do you want")
dog = await client.wait_for("message")
await message.channel.send("where do you want to live")
live = await client.wait_for("message")
await message.channel.send("what car do you want")
car = await client.wait_for("message")
await message.channel.send("what house do you want")
house = await client.wait_for("message")
await message.channel.send("Your dog is " + str(dog) + ", live in " + str(live) + ", have a " + str(car) + " , and your house is a " + str(house) + ".")```
I'm wondering how to make it say the actual content of the user message, not the message details. Other than that, it looks like it works fine.
答案 0 :(得分:0)
您只需执行 message.content
即可在 discord.py 中获取消息的内容。例如,
dog = (await client.wait_for("message")).content