'How to send an image to a channel from a url with a bot

soo i'm making a discord bot command which sends a random image that is generated by https://some-random-api.ml

now the problem is that the bot send a file img

here is my code

import aiohttp


import discord
from discord.ext import commands

class Misc(commands.Cog):

 def __init__(self, bot):
     self.bot = bot

 @commands.command()
 async def meme(self, ctx):
     async with aiohttp.ClientSession() as session:
         async with session.get('https://some-random-api.ml/meme') as resp:
             if resp.status != 200:
                 return await ctx.send('Could not download file...')
             data = io.BytesIO(await resp.read())
             await ctx.send(file=discord.File(data))
def setup(bot):
 bot.add_cog(Misc(bot))```


Solution 1:[1]

okaaaayyy I'm dumb i should have just change the response into a list then get the value that i wanted here is the code if someone had the same problem as me

    async def meme(self, ctx):
        async with aiohttp.ClientSession() as session:
            async with session.get('https://some-random-api.ml/meme') as resp:
                print(resp.status)
                answer = await (resp.read())
                obj = json.loads(answer)
                await ctx.send(list(obj.values())[2])
                await ctx.send(list(obj.values())[1])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SwirX