예제 #1
0
    async def oil_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.paint(), url)
                    file = discord.File(fp=img.image,
                                        filename=f"oil.{img.format}")
                    mbed = discord.Embed(title='Snap!', color=color)
                    mbed.set_image(url=f"attachment://oil.{img.format}")
                    mbed.set_footer(
                        text=
                        'Syntax: p! oil <image link> | Quality may be bad. Specify url if this is the case.'
                    )
                    await ctx.send(embed=mbed, file=file)
                except:
                    await ctx.send(embed=discord.Embed(
                        description=
                        '<:error:806618798768652318> Error when making request.',
                        color=color))
예제 #2
0
 async def paint(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.paint(), url)
     await ctx.send(
         file=discord.File(fp=img.image, filename=f"pixel.{img.format}"))
예제 #3
0
 async def oilify(self, ctx, url: str):
     try:
         img = await self.dagpi.image_process(ImageFeatures.paint(), url)
         mbed = discord.Embed(title='Snap!', color=0xf8de7e)
         mbed.set_image(url=f"attachment://oil.{img.format}")
         mbed.set_footer(
             text=f'Oil Painting Filter | Requested by {ctx.author}')
         file = discord.File(fp=img.image, filename=f"oil.{img.format}")
         await ctx.send(embed=mbed, file=file)
     except:
         await ctx.send(embed=discord.Embed(
             description=
             f'<:error:806618798768652318> Error when making request. | Image may be a WEBP file.',
             color=color))
예제 #4
0
파일: cog.py 프로젝트: avimetry/avimetry
 async def dag_paint(self, ctx: Context, *, item=None):
     """
     Makes your image look like it was painted.
     """
     meth = await self.do_dagpi(ctx, ImageFeatures.paint(), item)
     await self.dag_embed(ctx, meth, ctx.command.name)