#embed.set_image(url=image) where image is a PIL.Image

1 messages · Page 1 of 1 (latest)

clear lodge
#

How can I set an embed image without sending the image anywhere to create an image url?

torpid quail
#

I think that’s a discord limitation since it only takes a url

clear lodge
#

Should I just create some private server where my bot can send the image first, and then grab that url for embed.set_image(url=..)

torpid quail
#

that should work

languid wedge
#

?tag localfile

blazing prairieBOT
#
f = discord.File("some_file_path", filename="image.png")
e = discord.Embed()
e.set_image(url="attachment://image.png")
await messagable.send(file=f, embed=e)```
languid wedge
#

"some_file_path" can also be a Bytes object, which you probably have when working with PIL

clear lodge
#

I tried it with and without sending the file, and it doesn't add the image to the embed when I don't send the file

languid wedge
#

you have to use file

clear lodge
languid wedge
#

yes

#

what's stopping you from sending the file?

clear lodge
#

But I will just have a bytes file sent as well as the embed

#

and I don't want the byes file being sent as it clutters the channel

languid wedge
#

you misunderstand

#

that snippet is (equivalent to) discord's official solution to embedding an upload in an image

#

it will show up inside the embed instead of separately

clear lodge
#

I got it to work now thanks Nelo!

tawdry wasp
#

i tried sending a bytes array, but it shows and error

#

that's what xp_bar returns

#

dont know why, but i got it working using img_byte_arr.seek(0)

clear lodge