Ejemplo n.º 1
0
    async def poster_error(self, ctx, error):
        if isinstance(error, commands.CommandOnCooldown):
            errembed = discord.Embed(
                title='Hold on there, buddy',
                color=err_color,
                description=
                'Wait 3 more seconds before you can get another snap!')
            await ctx.send(embed=errembed)

        elif isinstance(error, commands.MissingRequiredArgument):
            async with self.ses.get(str(ctx.author.avatar_url)) as r:
                img = Image.open(BytesIO(await r.read()), mode='r')
                try:
                    img.seek(1)
                    url = str(ctx.author.avatar_url_as(format=f'gif'))
                except EOFError:
                    url = str(ctx.author.avatar_url_as(format=f'png'))

                try:
                    img = await self.dagpi.image_process(
                        ImageFeatures.poster(), url)
                    mbed = discord.Embed(title='Snap!', color=color)
                    mbed.set_image(url=f"attachment://posterized.{img.format}")
                    mbed.set_footer(
                        text=
                        f'Syntax: p! posterize <image link> | Quality may be bad. Specify url if this is the case.'
                    )
                    file = discord.File(fp=img.image,
                                        filename=f"posterized.{img.format}")
                    await ctx.send(embed=mbed, file=file)
                except:
                    await ctx.send(embed=discord.Embed(
                        description=
                        f'<:error:806618798768652318> Error when making request.',
                        color=color))
Ejemplo n.º 2
0
 async def posterize(self, ctx, member: discord.Member = None):
     await ctx.trigger_typing()
     if member is None:
         member = ctx.author
     url = str(
         member.avatar_url_as(format="png", static_format="png", size=1024))
     img = await self.bot.dagp.image_process(ImageFeatures.poster(), url)
     await ctx.send(
         file=discord.File(fp=img.image, filename=f"pixel.{img.format}"))
Ejemplo n.º 3
0
 async def posterize(self, ctx, url: str):
     try:
         img = await self.dagpi.image_process(ImageFeatures.poster(), url)
         file = discord.File(fp=img.image,
                             filename=f"posterized.{img.format}")
         mbed = discord.Embed(title='Snap!', color=color)
         mbed.set_image(url=f"attachment://posterized.{img.format}")
         mbed.set_footer(text=f'Posterized | Requested by {ctx.author} ')
         await ctx.send(embed=mbed, file=file)
     except:
         await ctx.send(embed=discord.Embed(
             description=
             f'<:error:806618798768652318> Error when making request.',
             color=color))
Ejemplo n.º 4
0
 async def dag_posterize(self, ctx: Context, *, item=None):
     """
     Posterize your image
     """
     meth = await self.do_dagpi(ctx, ImageFeatures.poster(), item)
     await self.dag_embed(ctx, meth, ctx.command.name)