【问题标题】:Attach and embed an image to Discord将图像附加并嵌入到 Discord
【发布时间】:2021-08-13 04:27:38
【问题描述】:

嗯,我见过一些可以嵌入图像的不和谐机器人。现在,这两个部分都很容易;附加图像并在嵌入中发送图像,但结合起来,我无法做到。 您可以附上图片:

discord.File(fp="yourfilename.png", filename= "newfilename.png")

你可以在 channel.send 中发送它,但你不能:

embed.set_image(url = "url")

您只能设置一个 url,因此图像必须已经存在于互联网上的某个地方...如何将两者结合起来,以便上传和嵌入新图像?

顺便说一句,我已经尝试过使用:

embed.set_image(file = discord.File(fp="yourfilename.png", filename= "newfilename.png"))

我很惊讶网上没有任何资源可以解释或举例说明,这应该是“常见”的事情。也许不可能?

【问题讨论】:

    标签: python python-3.x discord discord.py


    【解决方案1】:

    终于解决了:

    x = discord.File(r"C:\path\filename.png")
    embed = discord.Embed()
    embed.set_image(url = "attachment://filename.png")
    await channel.send(embed = embed, file = x)
    

    【讨论】:

      猜你喜欢
      • 2019-06-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-20
      • 2021-02-02
      • 2020-10-03
      • 2021-10-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多