【问题标题】:Making a picture show inside of embed in discord with python用python在嵌入不和谐中制作图片显示
【发布时间】:2021-12-01 02:07:06
【问题描述】:

我尝试了很多方法,但始终得到相同的结果。所以我想知道是否有人知道导致问题的原因?

每次我输入命令时,它都会先显示图片,然后像这样嵌入。 Current situation

但我想要它做的是将图像放在框架内。这是我目前拥有的代码。

@client.command()
  async def foto(ctx):
  channel = ctx.message.channel
  file_path_type = ["images/*.png"]
  images = glob.glob(random.choice(file_path_type))
  random_image = random.choice(images)
  random_image = random_image[7:len(random_image)]
  print(random_image)
  #await channel.send(file=discord.File(random_image))
  embed = discord.Embed(title="Een star wars icon", description="Zo eh! knap koppie.", 
  color=0x00ff00) 
  file = discord.File("images/"+ random_image, filename= "Star_Wars_Icon.png")
  embed.set_image(url="attachment://" + random_image)
  await channel.send(file=file, embed=embed)

是否有什么我忘记添加到代码中以便将图像放入框架中的内容?我对 python 很陌生,所以我已经为我的编码布局感到抱歉。

【问题讨论】:

    标签: python discord embed


    【解决方案1】:

    embed.set_image() 仅支持 HTTPS 链接。 您只能在嵌入中设置图像:

    embed = discord.Embed(title="Een star wars icon", description="Zo eh! knap koppie.", color=0x00ff00).set_image(url="https://some.link")
    

    【讨论】:

      猜你喜欢
      • 2020-10-17
      • 2020-08-26
      • 2021-07-17
      • 2021-05-14
      • 2020-09-27
      • 2017-05-05
      • 2020-12-31
      • 2022-10-23
      • 2020-11-12
      相关资源
      最近更新 更多