Ask coding questions

← Back to all posts
How to I import an image and use it to make a Discord bot?
Nithen (0)

So, I'm making a Discord bot and I want to make a bot that sends pictures of dragons when the user types "$dragon". So far, I have one image, and I have uploaded it to the Repl file tab. However, I don't know how to import the .gif file to my file. Please help me! I'm very new to Python and coding as a whole...

SixBeeps (5047)'s send() method has an option for passing in files. Here's what it looks like:

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

As long as you have the channel that they sent the message through, this will send the image in the same channel.

Nithen (0)

@SixBeeps I tried it, and its showing undefined name 'channel'. Should I give the name of the channel or something? Thanks in advance!

SixBeeps (5047)

@Nithen If you're using on_message, you can get the channel with Is it possible for you to link the Repl?

Nithen (0)

@SixBeeps yea sure.. but it's very long
Go near the last line to find the error-