diff options
| author | 2018-06-27 14:42:42 +0100 | |
|---|---|---|
| committer | 2018-06-27 14:42:42 +0100 | |
| commit | 8b23369ddd2a12bf15d50e782969d51e492e1795 (patch) | |
| tree | 78141a6af064e4faa4cee6513aad0f0e27f01dde | |
| parent | [Snekbox] Truncation that takes backticks into account (diff) | |
[Snekbox] Better truncation; don't use embeds because they wrap way too early
| -rw-r--r-- | bot/cogs/snekbox.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/bot/cogs/snekbox.py b/bot/cogs/snekbox.py index 60b87a85e..e228608b8 100644 --- a/bot/cogs/snekbox.py +++ b/bot/cogs/snekbox.py @@ -2,7 +2,6 @@ import datetime import logging from aio_pika import Message -from discord import Colour, Embed from discord.ext.commands import Bot, Context, command from bot.cogs.rmq import RMQ @@ -56,23 +55,22 @@ class Snekbox: async def callback(message: Message): output = message.body.decode() - colour = Colour.blurple() if "```" in output: output = "Code block escape attempt detected; will not output result" - colour = Colour.red() else: - output = [f"{i} | {line}" for i, line in enumerate(output.split("\n"), start=1)] + output = [f"{i:03d} | {line}" for i, line in enumerate(output.split("\n"), start=1)] output = "\n".join(output) - if len(output) >= 2040: - output = f"{output[:2000]}... (truncated)" + if len(output) >= 1900: + output = f"{output[:1900]}... (truncated)" - embed = Embed(description=f"```{output}```", title="Code evaluation", colour=colour) + await ctx.send( + f"{ctx.author.mention} Your eval job has completed.\n\n```{output}```" + ) await ctx.send( - f"{ctx.author.mention} Your eval job has completed.", - embed=embed + f"{ctx.author.mention} Your eval job has completed." ) del self.jobs[ctx.author.id] |