【问题标题】:(Discord.py) How can I get the entire embed content?(Discord.py) 如何获取整个嵌入内容?
【发布时间】:2021-02-18 14:46:16
【问题描述】:

我想获取所有嵌入内容(包括图片链接),我试过这个:

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>]

我在文档中找不到任何关于此的内容,只有关于发送嵌入的内容。

【问题讨论】:

    标签: python python-3.x discord discord.py


    【解决方案1】:

    你只是得到嵌入。根据 API References,您无法使用像 message.content 这样的一个函数来获取整个嵌入内容。您必须像Embed.title、Embed.description 和Embed.fields 一样逐个获取它。

    Embed.fields 返回表示字段内容的EmbedProxy 列表。 有关您可以访问的可能值,请参阅 add_field()。 如果属性没有值,则返回 Empty。

    也就是说,您可以获得嵌入标题、描述以及字段的名称和值。这是一个简单的例子:

    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'
    

    【讨论】:

    • 谢谢。应该可以,我也会阅读您发送的页面。
    猜你喜欢
    • 1970-01-01
    • 2019-01-12
    • 2021-02-20
    • 2014-01-12
    • 2021-04-09
    • 1970-01-01
    • 2021-01-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多