cutebear
cutebear

Reputation: 25

discord.py can not embed image from local file

I embed a image using this code, it doesn't throw any error and it send a embed but nothing is there in the embed.

e=discord.Embed()
file = discord.File("OWO.jpg", filename="OWO.jpg")
e.set_thumbnail(url="attachment://OWO.jpg")
msg = ctx.send(embed=e)

This is my embed image look like, There's nothing in it.

Upvotes: 1

Views: 2913

Answers (2)

Delta
Delta

Reputation: 370

How do I use a local image file for an embed image?

Discord special-cases uploading an image attachment and using it within an embed so that it will not display separately, but instead in the embed’s thumbnail, image, footer or author icon.

To do so, upload the image normally with abc.Messageable.send(), and set the embed’s image URL to attachment://image.png, where image.png is the filename of the image you will send.

Quick example:

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)

Note: Due to a Discord limitation, filenames may not include underscores.

Is there an event for audit log entries being created?

docs: https://discordpy.readthedocs.io/en/latest/faq.html#how-do-i-use-a-local-image-file-for-an-embed-image

Upvotes: 2

Łukasz Kwieciński
Łukasz Kwieciński

Reputation: 15689

You also need to send the file

msg = await ctx.send(embed=e, file=file)

Upvotes: 0

Related Questions