【问题标题】:Discord embed images not loading (Replit, Python)Discord 嵌入图像未加载(Replit,Python)
【发布时间】:2021-07-21 00:13:03
【问题描述】:

我在 Replit 上上传了一个示例图像,我正在尝试使用机器人将其嵌入到 Discord 消息中。我可以很好地创建嵌入,但图像似乎永远不会加载,就像这样:

如果我单击失败的图像并打开原件,它会将我带到带有正确图像的页面。我认为问题可能是我没有正确链接图像,或者 Discord 没有识别出链接是图像。代码:

if message.content.startswith('$img'):
   e = discord.Embed(title="Title", description="Desc", color=0x00ff00)
   e.set_image(url='https://replit.com/@Shazamin/Mythic-Tamer#images/species/slime.png')
   await message.channel.send(embed=e)

【问题讨论】:

标签: python discord


【解决方案1】:

找到了解决方案,如果以后有人需要的话:

if message.content.startswith('$img'):
   e = discord.Embed(title="Title", description="Desc", color=0x00ff00)
   file = discord.File("images/species/slime.png", filename="image.png")
   e.set_image(url="attachment://image.png")
   await message.channel.send(file=file, embed=e)

在这里找到答案:https://discordpy.readthedocs.io/en/latest/faq.html#how-do-i-use-a-local-image-file-for-an-embed-image

【讨论】:

    猜你喜欢
    • 2020-08-26
    • 2021-08-13
    • 2021-02-02
    • 2021-11-17
    • 1970-01-01
    • 2011-08-13
    • 1970-01-01
    • 1970-01-01
    • 2021-07-20
    相关资源
    最近更新 更多