【问题标题】:discord.py Invalid Form Body In embed.image.url: Scheme "<discord.file.file object at 0x000001e151c02360>" is not supporteddiscord.py embed.image.url 中的无效表单正文:不支持方案“<discord.file.file object at 0x000001e151c02360>”
【发布时间】:2021-06-16 11:13:27
【问题描述】:

我试过了

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 中:不支持方案“”。方案必须是 ('http', 'https') 之一。

我该如何修复这个错误?

【问题讨论】:

标签: python discord.py


【解决方案1】:

一切都在错误中,您正在尝试使用文件设置图像,但需要一个 url。

有一种方法可以将您的图像转换为一个 URL,该方法在 Discord.py FAQ 中进行了说明(重要的是阅读!)。

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

祝你有美好的一天!

【讨论】:

    猜你喜欢
    • 2021-08-17
    • 1970-01-01
    • 1970-01-01
    • 2019-11-17
    • 2021-11-07
    • 2021-10-12
    • 1970-01-01
    • 1970-01-01
    • 2019-09-15
    相关资源
    最近更新 更多