From 77687e93dd43ad8573e693c55b9d450c844f7cd0 Mon Sep 17 00:00:00 2001 From: Myned Date: Mon, 20 Nov 2017 02:20:30 -0500 Subject: [PATCH] Added error catching for SizeError --- src/main/cogs/booru.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/cogs/booru.py b/src/main/cogs/booru.py index 62a090a..4b764e4 100644 --- a/src/main/cogs/booru.py +++ b/src/main/cogs/booru.py @@ -357,7 +357,10 @@ class MsG: await ctx.message.add_reaction('\N{CROSS MARK}') except exc.MissingArgument: - await ctx.send('**Invalid url or file** Be sure the link directs to an image file', delete_after=7) + await ctx.send('**Invalid url or file.** Be sure the link directs to an image file', delete_after=7) + await ctx.message.add_reaction('\N{CROSS MARK}') + except exc.SizeError as e: + await ctx.send(f'`{e}` **too large.** Maximum is 8 MB', delete_after=7) await ctx.message.add_reaction('\N{CROSS MARK}') @commands.command(name='reversify', aliases=['revify', 'risify', 'rify']) @@ -408,6 +411,10 @@ class MsG: await ctx.send('`{} / {}` **No probable match for:** `{}`'.format(n, len(links), e), delete_after=7) await message.add_reaction('\N{CROSS MARK}') c -= 1 + except exc.SizeError as e: + await ctx.send(f'`{e}` **too large.** Maximum is 8 MB', delete_after=7) + await message.add_reaction('\N{CROSS MARK}') + c -= 1 finally: n += 1 @@ -451,6 +458,9 @@ class MsG: except exc.MatchError as e: await message.channel.send('**No probable match for:** `{}`'.format(e), delete_after=7) await message.add_reaction('\N{CROSS MARK}') + except exc.SizeError as e: + await message.channel.send(f'`{e}` **too large.** Maximum is 8 MB', delete_after=7) + await message.add_reaction('\N{CROSS MARK}') finally: await asyncio.sleep(self.RATE_LIMIT)