From 0d45b8b827512e49f50ea297a60aeece97a58aa3 Mon Sep 17 00:00:00 2001 From: "Dusty.P" Date: Tue, 5 Jun 2018 23:37:42 -0800 Subject: [PATCH] Modify exec --- exts/repl.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/exts/repl.py b/exts/repl.py index 490215c..aa4078c 100644 --- a/exts/repl.py +++ b/exts/repl.py @@ -37,6 +37,7 @@ class Repl: async def _eval(self, ctx, *, body: str): if ctx.author.id != ownerid: return + pag = Paginator() env = { 'bot': self.bot, 'ctx': ctx, @@ -60,8 +61,10 @@ class Repl: with redirect_stdout(stdout): ret = await func() except Exception: - value = stdout.getvalue() - await ctx.send('```py\n{}{}\n```'.format(value, traceback.format_exc())) + pag.add(stdout.getvalue()) + pag.add(traceback.format_exc()) + for page in pag.pages(): + await ctx.send(page) else: value = stdout.getvalue() # noinspection PyBroadException @@ -70,9 +73,9 @@ class Repl: except Exception: pass value = format_output(value) - pag = Paginator() pag.add(value) pag.add(f'\nReturned: {ret}') + self._last_result = ret for page in pag.pages(): await ctx.send(page)