I am currently writing a discord bot with discord.py Rewrite
and I want to attach an image onto an embed but I can't figure it out.
import discord
from discord.ext import commands
from discord import Embeds
crafting_table = Embed(title="Crafting Table", description=discord.File("./images/Crafting_Table_GUI.png"))
@client.command()
async def Info(ctx, *, question):
if "crafting table" in question:
await ctx.send(embed=crafting_table)
This is possible. Let me give an example.
# Rewrite
file = discord.File("filename.png") # an image in the same folder as the main bot file
embed = discord.Embed() # any kwargs you want here
embed.set_image(url="attachment://filename.png")
# filename and extension have to match (ex. "thisname.jpg" has to be "attachment://thisname.jpg")
await ctx.send(embed=embed, file=file)
If it is in a directory, you may do discord.File("images/filename.png", filename="filename.png"), but for the attachment:// url it is still just the name, no directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With