Reputation: 159
Rather than just sending an image, I want my discord bot to use Discord embed and have an image attached to it, however, when trying to use set_image and sending a new embed to discord no output is provided. I have a file named output.png in my project directory and I just want to see if I can use it within an embed. Here is some test code I used:
@client.command(name='test')
async def test(ctx):
embed = discord.Embed(title='test',colour=discord.Colour.dark_orange())
embed.set_image('output.png')
await ctx.send(embed=embed,file='output.png')
Why does this not produce an embed on discord?
Upvotes: 1
Views: 5225
Reputation: 718
The embed.set_image
method only accepts an URL of an image, and the file
kwarg of the send
method needs to be a File object, so if you want to send a locally saved image, you need to send it as a file along with the embed, then set the embed image using the attachment://image.png
URL; the image.png
can be changed.
file = discord.File("path/to/my/image.png", filename="output.png")
embed = discord.Embed()
embed.set_image(url="attachment://output.png")
await ctx.send(embed=embed, file=file)
See the FAQ
Upvotes: 2