#Embed image from slash command

1 messages · Page 1 of 1 (latest)

worldly crest
#
class imgbypass(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @slash_command(guild_ids=[purgMain],description="Used to bypass improper filtering of images.")  # Create a slash command for the supplied guilds.
    @commands.cooldown(1, 120, commands.BucketType.default)
    @commands.max_concurrency(2, per=commands.BucketType.default, wait=False)
    async def imgbypass(self,
            ctx,
            image: discord.Option(discord.Attachment, required=True),
                        ):
        if image.content_type not in allowed_content_types:
            return await ctx.respond("Invalid attachment, try a .png file or a .jpeg file!", ephemeral=True)
        else:
            '''EMBED IMAGE HERE SOMEHOW'''
            embed = discord.Embed(color=0x00B1FF)
            embed.set_author(name="test")
            await ctx.channel.edit(nsfw=True)
            await ctx.respond(embed=embed)
            await ctx.channel.edit(nsfw=False)

Trying to figure out how to turn that discord.attachment object to something I can put in the url field

worldly crest
#

yeah
embed.set_image(url="")

meager moss
#

?tag localfile

regal slateBOT
#
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)```
meager moss
#

basically that

#

or maybe i overthought it, image.url would work fine since the response isn't ephemeral

worldly crest
#

can you give me a brief example or just the docs for it

meager moss
#

for image.url? you already did it above

#

in set_image, just use image.url since it's a string

worldly crest
#

when using image.url the embed doesn't give me an error and sends the text portion but it also doesn't actually embed the image

meager moss
#

what happens when you print it?

#

or if you try to send it as content

worldly crest
#

caught a typo and it works fine now lmao

#

thanks so much for the help!

meager moss
#

allgood

worldly crest
#

is there a close command for this or just leave it be