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

2024-06-17 15:28:48 发布

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

我已经在Replit上上传了一个示例图像,我正试图使用bot将其嵌入到一条不和谐的消息中。我可以很好地创建嵌入,但图像似乎从未加载,如下所示:

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)

Tags: 代码图像消息示例messageif链接bot
1条回答
网友
1楼 · 发布于 2024-06-17 15:28:48

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

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

相关问题 更多 >