Send multiple embeds in one message with Discord.py

元气小坏坏 提交于 2021-01-01 19:48:18

问题


I've been trying to send a list of embeds in a single message using discord.py.

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)

embeds (List[Embed]) – A list of embeds to send with the content. Maximum of 10. This cannot be mixed with the embed parameter.

However, I get an error message when I try to pass the "embeds" parameter to the send() function:

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.

Here's my code :

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

This is supposed to send a single message containing 10 embeds every ten monsters.

I'm new to Python so I might have just made a stupid mistake. Thank you for your help!

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

回答1:


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) – The rich embed for the content.

Meaning the function only accepts an embed object, not a list of them.



来源:https://stackoverflow.com/questions/59563046/send-multiple-embeds-in-one-message-with-discord-py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!