From a94dcbb2b572cf006c8759db851a72934ae6cfe5 Mon Sep 17 00:00:00 2001 From: bmintz Date: Mon, 30 Jul 2018 00:15:31 -0500 Subject: [PATCH] cogs/emoji: flesh out local_check and add on_command_error --- cogs/emoji.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/cogs/emoji.py b/cogs/emoji.py index ca2a502..ddf7339 100644 --- a/cogs/emoji.py +++ b/cogs/emoji.py @@ -31,10 +31,25 @@ class Emotes: self.bot.config['user_agent'] + ' ' + self.bot.http.user_agent }) + async def __local_check(self, context): - return ( - context.guild - and context.author.guild_permissions.manage_emojis) + if not context.guild: + await context.send( + f'{utils.SUCCESS_EMOTES[False]} Sorry, this command may only be used in a server.') + return False + + if not context.author.guild_permissions.manage_emojis: + await context.send( + f'{utils.SUCCESS_EMOTES[False]} ' + "Sorry, you don't have enough permissions to run this command. " + 'You need the Manage Emojis permission.') + return False + + return True + + async def on_command_error(self, context, error): + if isinstance(error, errors.EmoteManagerError): + await context.send(str(error)) @commands.command() async def add(self, context, *args):