所以我用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)
有时可以,有时不可以。 (请参见下图)
我检查了库,发现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'}
关于我的问题,是否有人知道为什么有时正确显示图像,而有时却不正确?