diff options
author | 2018-10-21 22:52:15 +0530 | |
---|---|---|
committer | 2018-10-21 22:52:15 +0530 | |
commit | 138bb28e9d1cfef8cab48d216e550efafcd85454 (patch) | |
tree | f1b811224c5ad71e8e8a38f100cb8c36217fbcdf /bot/cogs | |
parent | Add pillow to Pipfile. (diff) |
Fix issues related to spookyavatar cog.
Diffstat (limited to 'bot/cogs')
-rw-r--r-- | bot/cogs/spookyavatar.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/bot/cogs/spookyavatar.py b/bot/cogs/spookyavatar.py index 11f4705c..d06b259a 100644 --- a/bot/cogs/spookyavatar.py +++ b/bot/cogs/spookyavatar.py @@ -1,9 +1,11 @@ +import aiohttp +from io import BytesIO + from discord.ext import commands import discord -import aiohttp -from PIL import ImageOps from PIL import Image -from io import BytesIO + +from bot.resources import spookifications class SpookyAvatar: @@ -16,12 +18,15 @@ class SpookyAvatar: self.bot = bot async def get(self, url): + """ + Returns the contents of the supplied url. + """ async with aiohttp.ClientSession() as session: async with session.get(url) as resp: return await resp.read() @commands.command(name='savatar', aliases=['spookyavatar', 'spookify'], brief='Spookify an user\'s avatar.') - async def repository(self, ctx, user: discord.Member=None): + async def spookyavatar(self, ctx, user: discord.Member=None): """ A command to print the user's spookified avatar. """ @@ -33,9 +38,8 @@ class SpookyAvatar: embed.set_author(name=str(user.name), icon_url=user.avatar_url) resp = await self.get(user.avatar_url) im = Image.open(BytesIO(resp)) - im = im.convert('RGB') - inv = ImageOps.invert(im) - inv.save(str(ctx.message.id)+'.png') + modified_im = spookifications.inversion(im) + modified_im.save(str(ctx.message.id)+'.png') f = discord.File(str(ctx.message.id)+'.png') embed.set_image(url='attachment://'+str(ctx.message.id)+'.png') await ctx.send(file=f, embed=embed) |