我一直在尝试使用 discord.py 在单个消息中发送嵌入列表.
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]) – 与内容一起发送的嵌入列表.最多 10 个.这不能与 embed 参数混合.
embeds (List[Embed]) – A list of embeds to send with the content. Maximum of 10. This cannot be mixed with the embed parameter.
但是,当我尝试通过嵌入"时收到一条错误消息.send() 函数的参数:
However, I get an error message when I try to pass the "embeds" parameter to the send() function:
TypeError: send() 得到了一个意外的关键字参数 '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 = []
这应该每十个怪物发送一条包含 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)"的内容.显示:
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 不允许在一条消息中发送多个嵌入.正如 在这里看到的 (并且已经在评论中提到由明)
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) – 内容的丰富嵌入.
意味着该函数只接受一个嵌入对象,而不是它们的列表.
Meaning the function only accepts an embed object, not a list of them.
这篇关于使用 Discord.py 在一条消息中发送多个嵌入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!