With Discord.py, is there a way to read embedded messages?

瘦欲@ 提交于 2020-08-09 07:22:07

问题


My code print out the message the user sends. However, when an embedded message gets sent, there is nothing on the terminal and nothing is read.

Is there a way for my bot to read embedded messages along with normal messages on discord

Python 3.8

client = discord.Client()

@client.event
async def on_message(message):
    print(message.content)

client.run(token)

回答1:


You can get list of embeds from message with message.embeds. Link for docs. Try this solution:

@client.event
async def on_message(message):
    embeds = message.embeds # return list of embeds
    for embed in embeds:
        print(embed.to_dict()) # it's content of embed in dict

P.S. If your message has one embed you can use: embed_content_in_dict = message.embeds[0].to_dict()



来源:https://stackoverflow.com/questions/62601894/with-discord-py-is-there-a-way-to-read-embedded-messages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!