简体   繁体   中英

Use local file as set_thumbnail on embed in Discord.py

I want to post an embed with a thumbnail on it, with a local file on my PC. Whenever I try to run this code, the image is sent outside the embed.

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)

The filename in the File constructor and the filename in the URL must match. Currently you're passing the whole path, it's supposed to be only the name

embedVar.set_thumbnail(url="attachment://image.png")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM