使用本地文件作为嵌入 Discord.py 中的 set_thumbnail

Lob*_*h67 4 python embed image discord discord.py

我想发布一个带有缩略图的嵌入内容,以及我电脑上的本地文件。每当我尝试运行此代码时,图像都会发送到嵌入之外。

embedVar = discord.Embed(title="title",
                        description="desc.",
                         color=0X19A6FF)
file = discord.File("file_location/file.png", filename="image.png")
embedVar.set_thumbnail(url="attachment://file_location/file.png")
await message.channel.send(file=file, embed=embedVar)
Run Code Online (Sandbox Code Playgroud)

Łuk*_*ski 6

构造函数中的文件名File和 中的文件名URL必须匹配。目前您正在传递整个路径,它应该只是名称

embedVar.set_thumbnail(url="attachment://image.png")
Run Code Online (Sandbox Code Playgroud)