Exemple #1
0
    async def snap_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.polaroid(),
                                                     url)
                mbed = discord.Embed(title='Snap!', color=color)
                mbed.set_image(url=f"attachment://polaroid.{img.format}")
                mbed.set_footer(
                    text=f'Polaroid Filter | Requested by {ctx.author}')
                file = discord.File(fp=img.image,
                                    filename=f"polaroid.{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))
    async def polaroid(self,
                       ctx: utils.CustomContext,
                       user: discord.Member = None):
        """Puts someones profile picture in a polaroid.
        Powered by Dagpi."""

        async with ctx.timeit:
            async with ctx.typing():
                user = user or ctx.author
                img_file = await do_dagpi_stuff(ctx, user,
                                                ImageFeatures.polaroid())
                await ctx.send("*Look at this photograph*", file=img_file)
Exemple #3
0
 async def snap(self, ctx, url: str):
     try:
         img = await self.dagpi.image_process(ImageFeatures.polaroid(), url)
         mbed = discord.Embed(title='Snap!', color=color)
         mbed.set_image(url=f"attachment://polaroid.{img.format}")
         mbed.set_footer(
             text=f'Polaroid Filter | Requested by {ctx.author}')
         file = discord.File(fp=img.image,
                             filename=f"polaroid.{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))
Exemple #4
0
 async def dag_polaroid(self, ctx: Context, *, item=None):
     """
     Make your image look like a polaroid picture
     """
     meth = await self.do_dagpi(ctx, ImageFeatures.polaroid(), item, False)
     await self.dag_embed(ctx, meth, ctx.command.name)