From 5168c025c5163dbf57267d4c3fde402c9b582897 Mon Sep 17 00:00:00 2001 From: Myned Date: Sun, 19 Nov 2017 23:05:38 -0500 Subject: [PATCH] Removed previous testing for lastcommand --- src/main/cogs/booru.py | 3 --- src/main/cogs/tools.py | 25 ++++++++++++------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/main/cogs/booru.py b/src/main/cogs/booru.py index a14b49e..1e1390d 100644 --- a/src/main/cogs/booru.py +++ b/src/main/cogs/booru.py @@ -1094,9 +1094,6 @@ class MsG: await ctx.send('**Request timed out**') await ctx.message.add_reaction('\N{CROSS MARK}') - # tools.command_dict.setdefault(str(ctx.author.id), {}).update( - # {'command': ctx.command, 'args': ctx.args}) - # @e621.error # async def e621_error(self, ctx, error): # if isinstance(error, exc.NSFW): diff --git a/src/main/cogs/tools.py b/src/main/cogs/tools.py index 5f7418a..d33d965 100644 --- a/src/main/cogs/tools.py +++ b/src/main/cogs/tools.py @@ -25,33 +25,32 @@ youtube = None tempfile.tempdir = os.getcwd() -command_dict = {} - class Utils: def __init__(self, bot): self.bot = bot - @commands.command(name='last', aliases=['l', ','], brief='Reinvokes last command', description='Reinvokes previous command executed', hidden=True) - async def last_command(self, ctx): - global command_dict + @commands.command(name='lastcommand', aliases=['last', 'l', ','], brief='Reinvokes last successful command', description='Executes last successfully executed command') + async def last_command(self, ctx, arg='None'): + try: + context = u.last_commands[ctx.author.id] - if command_dict.get(str(ctx.author.id), {}).get('args', None) is not None: - args = command_dict.get(str(ctx.author.id), {})['args'] - print(command_dict) - await ctx.invoke(command_dict.get(str(ctx.author.id), {}).get('command', None), args) + if arg == 'show' or arg == 'sh' or arg == 's': + await ctx.send(f'`{context.prefix}{context.invoked_with} {" ".join(context.args[2:])}`', delete_after=7) + else: + await ctx.invoke(context.command, *context.args[2:], **context.kwargs) + + except KeyError: + await ctx.send('**No last command**', delete_after=7) + await ctx.message.add_reaction('\N{CROSS MARK}') # Displays latency @commands.command(aliases=['p'], brief='Pong!', description='Returns latency from bot to Discord servers, not to user') @checks.del_ctx() async def ping(self, ctx): - global command_dict - await ctx.message.add_reaction('\N{TABLE TENNIS PADDLE AND BALL}') - await ctx.send(ctx.author.mention + ' \N{TABLE TENNIS PADDLE AND BALL} `' + str(round(self.bot.latency * 1000)) + 'ms`', delete_after=5) - command_dict.setdefault(str(ctx.author.id), {}).update({'command': ctx.command}) @commands.command(aliases=['pre'], brief='List bot prefixes', description='Shows all used prefixes') @checks.del_ctx()