为什么我的嵌入图像不总是显示?

时间:2020-09-22 21:06:07

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

所以我用python简单重写了this bot。 它获取链接并使用API​​返回Imageurl。

以下是相关代码:

@bot.command(name='ss')
async def screenshot(context, *args):
    if len(args) != 1:
        await context.channel.send("Error Missing Inspection Link!")
        return
    await context.message.add_reaction("✅")
    #Getting the Imageurl in a Class (sgg) in another Python File
    sgg.getscreenshot(args[0])
    while sgg.imglnk == "":
        sleep(0.2)
    e = discord.Embed(description=sgg.imglnk)
    e.set_image(url=sgg.imglnk)
    print(ppretty(e._image))
    await context.channel.send(embed=e)

有时可以,有时不可以。 (请参见下图)

enter image description here

我检查了库,发现Imageurl被放置在类成员Embed._image中。 因此,查看我是否收到格式错误的URL或我ppretty打印的类成员。 它为两个测试都返回了正确的URL。

https://s.swap.gg/rca4ofNZx.jpg
{'url': 'https://s.swap.gg/rca4ofNZx.jpg'}
https://s.swap.gg/DG-7kjyu6.jpg
{'url': 'https://s.swap.gg/DG-7kjyu6.jpg'}

关于我的问题,是否有人知道为什么有时正确显示图像,而有时却不正确?

0 个答案:

没有答案
相关问题