Search code examples
javascriptpythonpycord

Py Cord - Send two images to channel at once


I am trying to send at least two images to a channel at once however I am having no luck and I can not seem to find anything about it. I am trying to achieve something like this: https://prnt.sc/s7wg9b

async def test(
    ctx: discord.ApplicationContext,
    name: str,
    div: str,
    collar: str
):
    test = make_texture(name, collar, div)


    with open(str(test) + "_black_vest.png", 'rb') as f:
        picture = discord.File(f)

    with open(str(test) + "_black_vest.png", 'rb') as f:
        picture2 = discord.File(f)

    await ctx.send(
        file=picture + picture2
    )


Solution

  • You have two options, how to do it

    1. Simply sending two messages one after another:
    await ctx.send(file=picture)
    await ctx.send(file=picture2)
    
    1. Sending one message with multiple pictures pinned to it, using array:
    my_files = [picture, picture2]
    
    await ctx.send(files=my_files)
    

    Here are some useful links: