我试过了
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”之一。
如何修复此错误
所有内容都出错,您正试图使用文件设置图像,但需要url
有一种方法可以将图像转换为url,这在Discord.pyFAQ(阅读起来很重要!)中有解释
我认为How do I use a local image file for an embed image?问题与你的问题相对应
祝你今天愉快
相关问题 更多 >
编程相关推荐