示例#1
0
    async def glass_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.shatter(), url)
                    file = discord.File(fp=img.image,
                                        filename=f"shattered.{img.format}")
                    mbed = discord.Embed(title='Snap!', color=color)
                    mbed.set_image(url=f"attachment://shattered.{img.format}")
                    mbed.set_footer(
                        text=
                        f'Shattered Glass Filter | 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))
示例#2
0
 async def glass(self, ctx, url: str):
     try:
         img = await self.dagpi.image_process(ImageFeatures.shatter(), url)
         mbed = discord.Embed(title='Snap!', color=color)
         mbed.set_image(url=f"attachment://shattered.{img.format}")
         mbed.set_footer(
             text=f'Inverted Filter | Requested by {ctx.author}')
         file = discord.File(fp=img.image,
                             filename=f"shattered.{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))
示例#3
0
文件: cog.py 项目: avimetry/avimetry
 async def dag_shatter(self, ctx: Context, *, item=None):
     """
     Adds a glass break overlay to your image.
     """
     meth = await self.do_dagpi(ctx, ImageFeatures.shatter(), item)
     await self.dag_embed(ctx, meth, ctx.command.name)