【问题标题】:Attaching local thumbnail to Discord Embed将本地缩略图附加到 Discord Embed
【发布时间】:2021-10-27 16:13:22
【问题描述】:

我已经尝试了所有方法,但没有任何效果。如何在 Discord 中附加本地缩略图?图片在 images 目录中

msg.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)

缩略图未显示

【问题讨论】:

    标签: discord discord.py


    【解决方案1】:
    1. 您还必须发送文件
    2. set_thumbnail 中的 url 应该只是 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)
    

    【讨论】:

      猜你喜欢
      • 2020-09-20
      • 1970-01-01
      • 1970-01-01
      • 2021-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-21
      • 2017-12-08
      相关资源
      最近更新 更多