简体   繁体   中英

(Discord.py) How can I get the entire embed content?

I wanna get all the embed content(including the image link), I tried this:

print(msg.embeds)

And that's returning:

[<discord.embeds.Embed object at 0x000002E48768CD30>]
[<discord.embeds.Embed object at 0x000002E48768CAF0>]
[<discord.embeds.Embed object at 0x000002E487F04040>]
[<discord.embeds.Embed object at 0x000002E48768CA60>]
[<discord.embeds.Embed object at 0x000002E48768C9D0>]
[<discord.embeds.Embed object at 0x000002E487F043A0>]

I cant find anything about that on the documentation, only about sending embeds.

You're just getting embeds. According to API References, you can't get the whole embed content with one function like message.content . You have to get it part by part like Embed.title , Embed.description and Embed.fields .

Embed.fields Returns a list of EmbedProxy denoting the field contents. See add_field() for possible values you can access. If the attribute has no value then Empty is returned.

So that means, you can get embed title, description, and fields' name and value. Here's a simple example for this:

embed = discord.Embed(title='Example', description='Embed')
embed.add_field(name='field 1 name', value='field 1 value')
embed.add_field(name='field 2 name', value='field 2 value')
embed.title # returns 'Example'
embed.description # returns 'Embed'
embed.fields # returns a list of fields
embed.fields[0].name # returns 'field 1 name'
embed.fields[0].value # returns 'field 1 value'
embed.fields[1].name # returns 'field 2 name'
embed.fields[1].value # returns 'field 2 value'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM