Modify exec

release-1.0.0
DustyP 8 years ago
parent 8a68823f82
commit 0d45b8b827

@ -37,6 +37,7 @@ class Repl:
async def _eval(self, ctx, *, body: str): async def _eval(self, ctx, *, body: str):
if ctx.author.id != ownerid: if ctx.author.id != ownerid:
return return
pag = Paginator()
env = { env = {
'bot': self.bot, 'bot': self.bot,
'ctx': ctx, 'ctx': ctx,
@ -60,8 +61,10 @@ class Repl:
with redirect_stdout(stdout): with redirect_stdout(stdout):
ret = await func() ret = await func()
except Exception: except Exception:
value = stdout.getvalue() pag.add(stdout.getvalue())
await ctx.send('```py\n{}{}\n```'.format(value, traceback.format_exc())) pag.add(traceback.format_exc())
for page in pag.pages():
await ctx.send(page)
else: else:
value = stdout.getvalue() value = stdout.getvalue()
# noinspection PyBroadException # noinspection PyBroadException
@ -70,9 +73,9 @@ class Repl:
except Exception: except Exception:
pass pass
value = format_output(value) value = format_output(value)
pag = Paginator()
pag.add(value) pag.add(value)
pag.add(f'\nReturned: {ret}') pag.add(f'\nReturned: {ret}')
self._last_result = ret
for page in pag.pages(): for page in pag.pages():
await ctx.send(page) await ctx.send(page)

Loading…
Cancel
Save