簡體   English   中英

使用 Discord.py 在一封郵件中發送多個嵌入

[英]Send multiple embeds in one message with Discord.py

我一直在嘗試使用 discord.py 在單個消息中發送嵌入列表。

我在 discord.py 的文檔中看到這是可能的: https : //discordpy.readthedocs.io/en/latest/api.html

發送(內容=無,*,等待=假,用戶名=無,avatar_url=無,tts=假,文件=無,文件=無,嵌入=無,嵌入=無

embeds (List[Embed]) – 與內容一起發送的嵌入列表。 最多 10 個。這不能與嵌入參數混合。

但是,當我嘗試將“embeds”參數傳遞給 send() 函數時,我收到一條錯誤消息:

類型錯誤:send() 得到了一個意外的關鍵字參數“嵌入”

我需要有幾個嵌入,因為我想使用作者字段的圖標功能,我需要它們在同一條消息中,因為如果用戶添加反應,我想用嵌入的另一個列表替換這些嵌入。

這是我的代碼:

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

這個答案只是為了完成:Discord Bot API 不允許在一條消息中發送多個嵌入。 如此處所示(並且已在 Minn 的評論中提到)

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

這意味着該函數只接受一個嵌入對象,而不是它們的列表。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM