从sqlite3数据库附加文件到embed中

yvfmudvl  于 11个月前  发布在  SQLite
关注(0)|答案(1)|浏览(126)

我想发送一个嵌入图片,从sqlite3数据库。我正确地获取文件,但它不会显示在嵌入。

def init_embed(title, description, colour, picture):
    
    # Create a discord.File object from the image data
    file = discord.File(BytesIO(picture), filename='picture.png')

    # Name and description
    embed = discord.Embed(title=title,
                          description=description,
                          colour=colour)

    embed.set_image(url="attachment://oc_picture.png")  # Set the image using the discord.File object
   
    return embed

字符串
嵌入是正确发送的,图像只是因为某种原因不在那里。

wfveoks0

wfveoks01#

根据文档,您只需在上下文中发送嵌入和相关文件:

file = discord.File("path/to/my/image.png", filename="image.png")
embed = discord.Embed()
embed.set_image(url="attachment://image.png")
await channel.send(file=file, embed=embed)

字符串
这工作就像一个魅力!

相关问题