user11455925
user11455925

Reputation:

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

Upvotes: 3

Views: 2473

Answers (1)

Mixno
Mixno

Reputation: 412

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)

Upvotes: 3

Related Questions