获取来自用户/漫游器的回复消息

时间:2019-10-17 10:26:46

标签: python discord discord.py

基本上,通过以下代码从频道获取消息:

@client.event
async def on_message(message):
    if message.channel.name == 'somechannel':
        print("AUTHOR: %s CONTENT: %s" %(message.author,message.content))

所有纯文本答复都可以,并且可以正确打印,直到我收到这样的答复:

enter image description here

message.content我什么也没收到。如何获得回复消息的内容?

2 个答案:

答案 0 :(得分:1)

选中message.embeds,这将返回Embed对象的列表。

Embed具有可以检查的不同属性,例如Embed.titleEmbed.description

@client.event
async def on_message(message):
    if message.channel.name == 'somechannel':
        print("AUTHOR: %s CONTENT: %s" %(message.author,message.content))
        for embed in message.embeds:
            print(embed.title)
            print(embed.description)

答案 1 :(得分:1)

如果您使用的是python3.6 +,请尝试此操作

@client.event
async def on_message(message):
    if message.channel.name == 'somechannel':
        print(f"AUTHOR: {message.author} CONTENT:{message.content}")
        for embed in message.embeds:
            print(f"AUTHOR: {message.author} CONTENT: {embed.title} and {embed.description}")