首页 > 解决方案 > 将本地缩略图附加到 Discord Embed

问题描述

我已经尝试了一切,但没有任何工作。如何在 Discord 中附加本地缩略图?图像在图像目录中

在此处输入图像描述

味精.py:

embed = discord.Embed(title="Game Started", description=body)
embed.add_field(name=captain1, value=', '.join(team_one), inline=False)
embed.add_field(name=captain2, value=', '.join(team_two))
embed.set_thumbnail(url=f"attachment://images/elite.png")


await ctx.send(embed=embed)

缩略图不显示

标签: discorddiscord.py

解决方案


  1. 您还必须发送文件
  2. 中的 urlset_thumbnail应该只是attachment://{FILENAME},没有实际路径,因为它指的是消息的附件
file = discord.File("images/elite.png")

embed = discord.Embed(title="Game Started", description=body)
embed.add_field(name=captain1, value=', '.join(team_one), inline=False)
embed.add_field(name=captain2, value=', '.join(team_two))
embed.set_thumbnail(url=f"attachment://{file.filename}")  # you could just do `attachment://elite.png`, but this is a more "procedural" way

await ctx.send(embed=embed, file=file)

推荐阅读