【问题标题】:Send images in embeds discord.py在嵌入 discord.py 中发送图像
【发布时间】:2023-03-09 11:05:02
【问题描述】:

我正在尝试在 discord.py 中发送嵌入,但每当我运行代码时,都没有发送任何内容。没有错误什么都没有。这是我的代码:

from variables.variables import client, token
import discord


@client.command()
async def test(ctx):
    imageURL = "https://discordapp.com/assets/e4923594e694a21542a489471ecffa50.svg"
    embed = discord.Embed()
    embed.set_image(url=imageURL)
    await ctx.send(embed=embed)

client.run(token)

这是使用上述代码嵌入的样子:

谢谢!

【问题讨论】:

  • 您有on_command_error 事件吗?如果有,请在其中打印错误并发布错误。
  • 不,没有错误,我只是没有得到任何图像,我编辑帖子以显示嵌入的样子
  • 您确定支持 .svg 类型吗?
  • 不,但这是我从另一个 stackoverflow 问题中使用的图像链接,询问如何在嵌入中发送图像,因为我不知道如何制作图像 http 或 https
  • 你能尝试一些随机的 .png 图片作为 url 吗?所以你可以弄清楚问题是不是文件类型。

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


【解决方案1】:

.svg 不受支持。这是.png 格式的同一张图片:

@client.command()
async def test(ctx):
    imageURL = "https://cdn.discordapp.com/attachments/744631318578462740/755866713182044240/ezgif-4-6eba1fde99f2.png"
    embed = discord.Embed()
    embed.set_image(url=imageURL)
    await ctx.send(embed=embed)

【讨论】:

  • 非常感谢,它成功了,但是您是如何将.svg 文件转换为.png
  • 网上有很多网站可以做到,只要谷歌“svg to png”。
猜你喜欢
  • 2021-01-25
  • 2021-02-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-31
  • 2021-02-13
  • 1970-01-01
  • 2021-10-20
相关资源
最近更新 更多