Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to interact with attached image in discord.py

I want my bot interact with the image that attached to the message to it. It will get the image and store it to itself. How to write code like that?

here the part of current code :

@bot.command()
async def hello(ctx):
    await ctx.send(embeds)

that's all, i hope you can and may help me


1 Answers

You can resend images like that:

@bot.command()
async def hello(ctx):
    files = []
    for file in ctx.message.attachments:
        fp = BytesIO()
        await file.save(fp)
        files.append(discord.File(fp, filename=file.filename, spoiler=file.is_spoiler()))
    await ctx.send(files=files)
like image 180
Mixno Avatar answered Dec 06 '25 14:12

Mixno