Python 使用discord.py是否有办法读取嵌入并将嵌入的一部分存储为变量?

Python 使用discord.py是否有办法读取嵌入并将嵌入的一部分存储为变量?,python,discord.py,Python,Discord.py,我曾尝试在嵌入中查找关键字,但这给了我一个错误,即类型不可编辑,它用于discord bot游戏,我希望它读取嵌入的配置文件,然后将玩家的统计数据存储为变量,但我找不到方法来做到这一点 @bot.command(name='dungeon') async def dungeon(ctx): @bot.event async def on_message(message): embeds = message.embeds # return list of embed

我曾尝试在嵌入中查找关键字,但这给了我一个错误,即类型不可编辑,它用于discord bot游戏,我希望它读取嵌入的配置文件,然后将玩家的统计数据存储为变量,但我找不到方法来做到这一点

@bot.command(name='dungeon')
async def dungeon(ctx):
    @bot.event
    async def on_message(message):
        embeds = message.embeds # return list of embeds
        for embed in embeds:
            print(embed.to_dict())
            if '**AT**' in embeds[0]:
                print('found')

您可以在嵌入的项目上循环,并查找
项目.name
项目.value

第一行是仅获取消息中的第一个嵌入项,您可以编辑该嵌入项以循环所有嵌入项

p.S.I添加了关于如何更新项目名称或值的方法。如果你想这样做

embed=message.embeds[0]
对于i,枚举中的项(嵌入.fields):
如果item.name中的“**AT**”:
打印(f'found{item.value}')
#要更新嵌入的
embed.set_field_at(index=i,name=item.name,inline=item.inline,value='NEWVALUE')
等待消息。编辑(嵌入=嵌入)