I want to let my Discord Bot send images/gifs

I know your problem is already solved, but I will post an answer so that people who have this same problem will be able to find the solution easily.

To send an image or GIF, here are two options (adapted from here):

  1. Opening the file and sending it directly to the channel:

    with open('my_image.png', 'rb') as f:
        picture = discord.File(f)
        await channel.send(file=picture)
    
  2. Passing the file name directly:

    await channel.send(file=discord.File('my_image.png'))
    

Here are some useful links:

Leave a Comment