From 254a0d95b4496494795b2ad8112d95df2a6f1a62 Mon Sep 17 00:00:00 2001 From: Myned Date: Thu, 14 Jun 2018 21:15:03 -0400 Subject: [PATCH 1/4] Catch database error --- src/cogs/booru.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cogs/booru.py b/src/cogs/booru.py index a8ec4de..bf96b1a 100644 --- a/src/cogs/booru.py +++ b/src/cogs/booru.py @@ -450,6 +450,9 @@ class MsG: 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}') + except Exception: + await ctx.send('**The image database is offline.** Please try again later') + await ctx.message.add_reaction('\N{CROSS MARK}') @cmds.command(name='reversify', aliases=['revify', 'risify', 'rify']) async def reversify(self, ctx, *args): @@ -525,6 +528,9 @@ class MsG: except exc.BoundsError as e: await ctx.send('`{}` **invalid limit.** Query limited to 30'.format(e), delete_after=7) await ctx.message.add_reaction('\N{CROSS MARK}') + except Exception: + await ctx.send('**The image database is offline.** Please try again later') + await ctx.message.add_reaction('\N{CROSS MARK}') async def _reversify(self): while self.reversifying: From f7c7247b9204168bc95b7f88ace63cc37ab34934 Mon Sep 17 00:00:00 2001 From: Myned Date: Thu, 14 Jun 2018 21:15:25 -0400 Subject: [PATCH 2/4] Fix GoTo breaking in DMs --- src/cogs/booru.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cogs/booru.py b/src/cogs/booru.py index bf96b1a..e72c203 100644 --- a/src/cogs/booru.py +++ b/src/cogs/booru.py @@ -833,7 +833,9 @@ class MsG: icon_url=self._get_score(values[c - 1]['score'])) embed.set_image(url=values[c - 1]['file_url']) - await number.delete() + if ctx.channel is d.TextChannel: + with suppress(errext.CheckFailure): + await number.delete() await paginator.edit(content='\N{HEAVY BLACK HEART}' if keys[c - 1] in hearted.keys() else None, embed=embed) @@ -973,7 +975,9 @@ class MsG: icon_url=self._get_score(values[c - 1]['score'])) embed.set_image(url=values[c - 1]['file_url']) - await number.delete() + if ctx.channel is d.TextChannel: + with suppress(errext.CheckFailure): + await number.delete() await paginator.edit(content='\N{HEAVY BLACK HEART}' if keys[c - 1] in hearted.keys() else None, embed=embed) From a732f4e8e29570699051ae72c0bc403d47874dd0 Mon Sep 17 00:00:00 2001 From: Myned Date: Thu, 14 Jun 2018 21:16:54 -0400 Subject: [PATCH 3/4] Fix for discord.py upgrade --- src/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/run.py b/src/run.py index e6964ff..dd44690 100644 --- a/src/run.py +++ b/src/run.py @@ -82,7 +82,7 @@ async def on_ready(): # bot.loop.create_task(u.clear(booru.temp_urls, 30*60)) if u.config['playing'] is not '': - await bot.change_presence(game=d.Game(name=u.config['playing'])) + await bot.change_presence(activity=d.Game(name=u.config['playing'])) print('\n> > > > > > > > >\nC O N N E C T E D : {}\n> > > > > > > > >\n'.format(bot.user.name)) await bot.get_channel(u.config['info_channel']).send(f'**Started** \N{BLACK SUN WITH RAYS} `{"` or `".join(u.config["prefix"])}`') From 9ea9c23426dfd9b9dbb6924439b47847cf0ff4cd Mon Sep 17 00:00:00 2001 From: Myned Date: Thu, 14 Jun 2018 21:24:52 -0400 Subject: [PATCH 4/4] Fix error reporting --- src/run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/run.py b/src/run.py index dd44690..34e760a 100644 --- a/src/run.py +++ b/src/run.py @@ -172,8 +172,8 @@ async def on_command_error(ctx, error): print('\n! ! ! ! ! ! ! ! ! ! ! !\nC O M M A N D E R R O R : {}\n! ! ! ! ! ! ! ! ! ! ! !\n'.format( error), file=sys.stderr) tb.print_exception(type(error), error, error.__traceback__, file=sys.stderr) - await bot.get_user(u.config['owner_id']).send('**COMMAND ERROR** \N{WARNING SIGN} `{}` from {} in {}\n```\n{}```'.format(ctx.message.content, ctx.author.mention, ctx.channel.mention if ctx.channel is d.channel.TextChannel else 'DMs', error)) - await bot.get_channel(u.config['info_channel']).send('**COMMAND ERROR** \N{WARNING SIGN} `{}` from {} in {}\n```\n{}```'.format(ctx.message.content, ctx.author.mention, ctx.channel.mention if ctx.channel is d.channel.TextChannel else 'DMs', error)) + await bot.get_user(u.config['owner_id']).send('**COMMAND ERROR** \N{WARNING SIGN} `{}` from {} in {}\n```\n{}```'.format(ctx.message.content, ctx.author.mention, ctx.channel.mention if isinstance(ctx.channel, d.channel.TextChannel) else 'DMs', error)) + await bot.get_channel(u.config['info_channel']).send('**COMMAND ERROR** \N{WARNING SIGN} `{}` from {} in {}\n```\n{}```'.format(ctx.message.content, ctx.author.mention, ctx.channel.mention if isinstance(ctx.channel, d.channel.TextChannel) else 'DMs', error)) await exc.send_error(ctx, error) await ctx.message.add_reaction('\N{WARNING SIGN}') # u.notify('C O M M A N D E R R O R')