embed.image.url中的discord.py表单正文无效:不支持方案“<discord.file.file object at 0x000001e151c02360>”

2024-03-28 19:55:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我试过了

data_stream = io.BytesIO()
    data_stream.seek(0)

    l = ['Communication', 'dress', 'food', 'culture', 'other']
    plt.pie(r, labels=l, autopct='%.1f%%')
    plt.savefig(str(ctx.author))
    chart = discord.File(data_stream, filename=f"{str(ctx.author)}.png")
    
    embed = discord.Embed(title = 'ㅁㄴㅇㄹ', description = 'ㅁㄴㅇㄹd')
    embed.set_image(url=chart)
    plt.close()
    await ctx.send(embed=embed)

但是错误

无效的表单正文 在embed.image.url中:不支持方案“<;位于0x000001e151c02360>;的discord.file.file对象”。方案必须是 “http”、“https”之一。

如何修复此错误


Tags: ioimageurldatastream错误chart方案
1条回答
网友
1楼 · 发布于 2024-03-28 19:55:56

所有内容都出错,您正试图使用文件设置图像,但需要url

有一种方法可以将图像转换为url,这在Discord.pyFAQ(阅读起来很重要!)中有解释

我认为How do I use a local image file for an embed image?问题与你的问题相对应

祝你今天愉快

相关问题 更多 >