問題描述
我一直在嘗試使用 discord.py 在單個消息中發(fā)送嵌入列表.
I've been trying to send a list of embeds in a single message using discord.py.
我在 discord.py 的文檔中看到它是可能的:https://discordpy.readthedocs.io/en/latest/api.html
I've seen it was possible in discord.py's documentation: https://discordpy.readthedocs.io/en/latest/api.html
send(content=None, *, wait=False, username=None, avatar_url=None, tts=False, file=None, files=None, embed=None, embeds=None)
send(content=None, *, wait=False, username=None, avatar_url=None, tts=False, file=None, files=None, embed=None, embeds=None)
embeds (List[Embed]) – 與內(nèi)容一起發(fā)送的嵌入列表.最多 10 個.這不能與 embed 參數(shù)混合.
embeds (List[Embed]) – A list of embeds to send with the content. Maximum of 10. This cannot be mixed with the embed parameter.
但是,當我嘗試通過嵌入"時收到一條錯誤消息.send() 函數(shù)的參數(shù):
However, I get an error message when I try to pass the "embeds" parameter to the send() function:
TypeError: send() 得到了一個意外的關(guān)鍵字參數(shù) 'embeds'
TypeError: send() got an unexpected keyword argument 'embeds'
我需要有幾個嵌入,因為我想使用作者字段的圖標功能,并且我需要它們在同一條消息中,因為如果用戶添加反應,我想用嵌入上的另一個列表替換這些嵌入.
I need to have several embeds because I'd like to use the author field's icon feature, and I need them in the same message because I want to replace these embeds by another list on embeds if the user adds a reaction.
這是我的代碼:
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 = []
這應該每十個怪物發(fā)送一條包含 10 個嵌入的消息.
This is supposed to send a single message containing 10 embeds every ten monsters.
我是 Python 新手,所以我可能只是犯了一個愚蠢的錯誤.感謝您的幫助!
I'm new to Python so I might have just made a stupid mistake. Thank you for your help!
這是print(embedList)"的內(nèi)容.顯示:
EDIT : Here is what "print(embedList)" displays :
[<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 不允許在一條消息中發(fā)送多個嵌入.正如 在這里看到的 (并且已經(jīng)在評論中提到由明)
This answer is only for the sake of completion: The Discord Bot API allows for no way of sending multiple embeds in one message. As seen here (and already mentioned in the comments by Minn)
embed (Embed) – 內(nèi)容的豐富嵌入.
意味著該函數(shù)只接受一個嵌入對象,而不是它們的列表.
Meaning the function only accepts an embed object, not a list of them.
這篇關(guān)于使用 Discord.py 在一條消息中發(fā)送多個嵌入的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!