(Discord.py)如何获取整个嵌入内容? [英] (Discord.py) How can I get the entire embed content?

查看:35
本文介绍了(Discord.py)如何获取整个嵌入内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取所有嵌入内容(包括图像链接),我尝试过此操作:

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参考,您无法使用 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 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'

这篇关于(Discord.py)如何获取整个嵌入内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆