問題描述
我想獲取所有嵌入內容(包括圖片鏈接),我試過這個:
I wanna get all the embed content(including the image link), I tried this:
print(msg.embeds)
這又回來了:
[<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.
推薦答案
你只是得到嵌入.根據 API References,您無法使用 message.content
之類的一個函數來獲取整個嵌入內容.您必須像 Embed 那樣逐部分獲取它.標題
,嵌入.description
和 Embed.fields
.
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
返回表示字段內容的 EmbedProxy
列表.有關您可以訪問的可能值,請參閱 add_field().如果屬性沒有值,則返回 Empty.
Embed.fields
Returns a list ofEmbedProxy
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'
這篇關于(Discord.py) 如何獲取整個嵌入內容?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!