如何使用机器人将图像从 url 发送到频道

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

soo 我正在制作一个 discord bot 命令,它发送一个由生成的随机图像 https://some-random-api.ml

现在的问题是机器人发送了一个文件img

这是我的代码

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))```

okaaaayyy 我很笨,我应该将响应更改为列表,然后获取我想要的值,如果有人遇到与我相同的问题,这里是代码

    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])