from PIL import Image, ImageDraw, ImageFont
@client.command()
async def test(ctx):
image = Image.open('background.png')
font = ImageFont.truetype('arial.ttf', size=35)
draw.text((0, 0), f"Example", fill="white", font=font)
draw.save("image.png")
await ctx.send(File=discord.File("image.png"))
Run Code Online (Sandbox Code Playgroud)
我将如何发送创建的图像而Pillow.py无需先保存图像。我试图通过 Stack Overflow 搜索来找到对此的有效响应,但是我没有找到任何有效的方法。任何帮助表示赞赏!之前我尝试使用 IO 来解决这个问题,但最终只是发送空文件。