Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
435 views
in Technique[技术] by (71.8m points)

python 3.x - With Discord.py, is there a way to read embedded messages?

My code prints 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)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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()


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...