def magik(self, ctx, target, *args):
""" Add some magik to your boring-ass images """
try:
member = await commands.MemberConverter().convert(ctx, target)
url = member.avatar_url
except:
url = target
url = url.replace("gif", "png").strip("<>")
if args:
opt = args[0]
else:
opt = 0.5
multi = parsers.as_number(opt, 0.5)
if multi > 10:
return await ctx.send('Maximum multiplier is 10')
m = await ctx.send("pls wait am generating")
try:
b = BytesIO()
async with aiohttp.ClientSession() as session:
async with session.get(url) as r:
with wand.image.Image(file=BytesIO(await r.read())) as img:
img.transform(resize="400x400")
img.liquid_rescale(width=int(img.width * 0.5),
height=int(img.height * 0.5),
delta_x=multi,
rigidity=0)
img.liquid_rescale(width=int(img.width * 1.5),
height=int(img.height * 1.5),
delta_x=2,
rigidity=0)
img.save(file=b)
b.seek(0)
await ctx.send(file=discord.File(b, filename="magik.png"))
await m.delete()
except:
await m.edit(content="Unable to generate image. Provide a mention or valid URL.")
评论列表
文章目录