def export_image(ctx: DogbotContext, image: Image, filename: str):
with BytesIO() as bio:
# Export the image.
coro = ctx.bot.loop.run_in_executor(None, functools.partial(image.save, bio, format='png'))
await asyncio.wait([coro], loop=ctx.bot.loop, timeout=5)
# Upload to the channel.
bio.seek(0)
await ctx.send(file=discord.File(bio, filename))
评论列表
文章目录