我想发送来自 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
嵌入已正确发送,只是由于某种原因图像不存在。
根据文档,您只需在上下文中发送嵌入内容和相关文件:
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)
这就像一个魅力!