使用Discord.py在一条消息中发送多个嵌入

时间:2020-01-02 12:02:12

标签: python discord.py

我一直在尝试使用discord.py在单个消息中发送嵌入列表。

我在discord.py的文档中看到了这种可能性:https://discordpy.readthedocs.io/en/latest/api.html

发送(内容=无,*,等待= False,用户名=无,avatar_url =无,tts = False,文件=无,文件=无,嵌入=无,嵌入式=无

embeds(List [Embed])–与内容一起发送的嵌入列表。最多10个。不能与embed参数混合使用。

但是,当我尝试将“ embeds”参数传递给send()函数时,我收到一条错误消息:

TypeError:send()得到了意外的关键字参数'embeds'

我需要使用多个嵌入,因为我想使用author字段的图标功能,并且在同一封邮件中需要它们,因为如果用户添加反应,我想用另一个嵌入列表替换这些嵌入。< / p>

这是我的代码:

embedList = []
for monster in monsters:
    embed = discord.Embed(color= 0x202225)
    embed.set_author(name=monster['name'], icon_url="https://ochabot.co/sprites/16/" + str(monster["family"]) + "_" + str(monster["species"]) + "_discord.png")
    embedList.append(embed)
    if(len(embedList) == 10):
        print(embedList)
        await message.channel.send(embeds=embedList)
        embedList = []

这应该每10个怪物发送一条包含10个嵌入的消息。

我是Python的新手,所以我可能犯了一个愚蠢的错误。谢谢您的帮助!

编辑: 这是“ print(embedList)”显示的内容:

[<discord.embeds.Embed object at 0x7fd3552d9dc8>, <discord.embeds.Embed object at 0x7fd3552d9e58>, <discord.embeds.Embed object at 0x7fd3552d9ee8>, <discord.embeds.Embed object at 0x7fd3552d9f78>, <discord.embeds.Embed object at 0x7fd354274048>, <discord.embeds.Embed object at 0x7fd3542740d8>, <discord.embeds.Embed object at 0x7fd354274168>, <discord.embeds.Embed object at 0x7fd3542741f8>, <discord.embeds.Embed object at 0x7fd354274288>, <discord.embeds.Embed object at 0x7fd354274318>]

1 个答案:

答案 0 :(得分:0)

此答案仅出于完成目的:Discord Bot API不允许在一条消息中发送多个嵌入。正如seen here(并且已经在Minn的评论中提及)

embed (Embed) – The rich embed for the content.

意味着该功能仅接受一个嵌入对象,而不接受它们的列表。