Discord.py 机器人说的是消息的详细信息(例如消息 ID、频道 ID、作者等)而不是消息的内容
Discord.py bot saying message details (such as message id, channel id, author etc) rather than the content of the message
作为参考,我对 python 还很陌生,所以了解不多。我正在为我正在开发的 discord 机器人创建一个非常简单的 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.
您只需执行 message.content
即可获取 discord.py 中的消息内容。例如,
dog = (await client.wait_for("message")).content
作为参考,我对 python 还很陌生,所以了解不多。我正在为我正在开发的 discord 机器人创建一个非常简单的 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.
您只需执行 message.content
即可获取 discord.py 中的消息内容。例如,
dog = (await client.wait_for("message")).content