From 19c8213fdd1e58aae2c5566c33bbc6f7a345abd1 Mon Sep 17 00:00:00 2001 From: FrenchMasterSword Date: Sat, 5 Jan 2019 22:43:15 +0100 Subject: Raised exception now returns full traceback. Also directly returns "[No output]" if code is only composed of comments, to avoid breaking try/except. --- bot/cogs/snekbox.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bot/cogs/snekbox.py b/bot/cogs/snekbox.py index 0b9aa1b45..1be524c1e 100644 --- a/bot/cogs/snekbox.py +++ b/bot/cogs/snekbox.py @@ -30,7 +30,8 @@ exec(open(venv_file).read(), dict(__file__=venv_file)) try: {CODE} except Exception as e: - print("{}: {}".format(e.__class__.__name__, e)) + import traceback + print(traceback.format_exc(), end='') """ ESCAPE_REGEX = re.compile("[`\u202E\u200B]{3,}") @@ -86,6 +87,11 @@ class Snekbox: if not code: # None or empty string return await ctx.invoke(self.bot.get_command("help"), "eval") + if all([line.startswith('#') for line in code.strip('\n')]): # Only comments + return await ctx.send( + f"{ctx.author.mention} Your eval job has completed.\n\n```py\n[No output]\n```" + ) + log.info(f"Received code from {ctx.author.name}#{ctx.author.discriminator} for evaluation:\n{code}") self.jobs[ctx.author.id] = datetime.datetime.now() -- cgit v1.2.3