使用Discord.py在一条消息中发送多个嵌入 [英] Send multiple embeds in one message with Discord.py

查看:51
本文介绍了使用Discord.py在一条消息中发送多个嵌入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用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

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

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'

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

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个怪物发送一条包含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不允许在一条消息中发送多个嵌入.如在此处看到(并且已在评论中提及通过Minn)

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(嵌入)–内容的丰富嵌入.

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

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

这篇关于使用Discord.py在一条消息中发送多个嵌入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆