如何从url裁剪图像并将其作为嵌入到Discord中发送

2024-09-27 20:15:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我刚开始学习python,并尝试创建一个discord机器人。以下是一段代码片段:

prefix = "https://render-tron.appspot.com/screenshot/https://brilliant.org/"
  
@bot.command(pass_context=True)
async def daily(ctx):
    img_url = prefix + "daily-problems/"
    embedVar = discord.Embed(Title = "Brilliant", url = "https://brilliant.org")
    embedVar.set_image(url = img_url)
    await ctx.send(embed = embedVar) 

输出:Image of the bot output

如何裁剪图像并将其嵌入?我尝试从url保存图像,然后使用PIL进行裁剪,但这是一个漫长的过程。还有别的办法吗


Tags: 代码httpsorg图像urlimgprefixbot

热门问题