diff options
Diffstat (limited to 'bot')
-rw-r--r-- | bot/cogs/spookyavatar.py | 18 | ||||
-rw-r--r-- | bot/resources/spookifications.py | 7 |
2 files changed, 18 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) diff --git a/bot/resources/spookifications.py b/bot/resources/spookifications.py new file mode 100644 index 00000000..aeb8388b --- /dev/null +++ b/bot/resources/spookifications.py @@ -0,0 +1,7 @@ +from PIL import ImageOps + + +def inversion(im): + im = im.convert('RGB') + inv = ImageOps.invert(im) + return inv |