0ugs
0ugs

Reputation: 21

Is there way to send image with discord.py bot hosted by heroku?

Is there a way to save and send photos from a discord.py bot hosted by Heroku?

Upvotes: 0

Views: 82

Answers (1)

Ratery
Ratery

Reputation: 2917

Firstly, move your photos to a bot's directory and push them to your GitHub repository. Then deploy the project on heroku. To send a photo (file) use this:

@bot.command()
async def send_photo(ctx):
    await ctx.send(discord.File("photo.png"))

This command sends a photo called photo.png.

To send random photo you can use random.choice() function from random module:

import random

PHOTOS = ["photo1.png", "photo2.png", "photo3.png"]

@bot.command()
async def send_photo(ctx):
    await ctx.send(discord.File(random.choice(PHOTOS)))

Upvotes: 1

Related Questions