Discord 嵌入图像未加载(Replit,Python)

时间:2021-07-19 10:23:43

标签: python discord

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

discord embed

如果我单击失败的图像并打开原始图像,它会将我正确地带到带有图像的页面。我相信问题可能是我没有正确链接图像,或者 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)

1 个答案:

答案 0 :(得分:0)

找到了一个解决方案,如果将来有人需要的话:

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

相关问题