首页 > 解决方案 > 如何从discordpy中的文件发送图像

问题描述

所以基本上我正在尝试从 discord.py 中的文件夹发送图像。我想不通。这是我到目前为止所拥有的......

async def neko(ctx):
    neko =[]

    for x in os.listdir("neko"):
        neko.append(x)


    await ctx.send(random.choice(neko))```

It sends the filename but it does not send the actual image. 

标签: pythondiscord.py-rewrite

解决方案


你没有完全得到图像。试试下面的代码,如果它不起作用,你可以随时使用这个PIL

async def neko(ctx):
    neko_list =[]

    for x in os.listdir("neko"):
        neko_list.append(x)

    neko = random.choice(neko_list)
    await ctx.send(file=discord.File(neko))

推荐阅读