diff options
| author | 2019-01-05 22:43:15 +0100 | |
|---|---|---|
| committer | 2019-01-05 22:43:15 +0100 | |
| commit | 19c8213fdd1e58aae2c5566c33bbc6f7a345abd1 (patch) | |
| tree | f5c57e2f52df3890d7d26eda6f738f16dae39132 | |
| parent | Added Name of exception's class in traceback. (diff) | |
Raised exception now returns full traceback.
Also directly returns "[No output]" if code is
only composed of comments, to avoid breaking try/except.
| -rw-r--r-- | bot/cogs/snekbox.py | 8 |
1 files changed, 7 insertions, 1 deletions
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() |