aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Numerlor <[email protected]>2020-05-06 02:47:15 +0200
committerGravatar Numerlor <[email protected]>2020-05-06 02:47:15 +0200
commit077a1ef1eb4eb07325dde5b6b625a84ccb5669ee (patch)
tree9aa39cbf42aad6a375ad96552bfb3685e8cd099d
parentHandle failed paste uploads. (diff)
Use new util function for uploading output.
-rw-r--r--bot/cogs/snekbox.py13
1 files changed, 2 insertions, 11 deletions
diff --git a/bot/cogs/snekbox.py b/bot/cogs/snekbox.py
index 8d4688114..2aab8fdb1 100644
--- a/bot/cogs/snekbox.py
+++ b/bot/cogs/snekbox.py
@@ -14,6 +14,7 @@ from discord.ext.commands import Cog, Context, command, guild_only
from bot.bot import Bot
from bot.constants import Categories, Channels, Roles, URLs
from bot.decorators import in_whitelist
+from bot.utils import send_to_paste_service
from bot.utils.messages import wait_for_deletion
log = logging.getLogger(__name__)
@@ -70,17 +71,7 @@ class Snekbox(Cog):
if len(output) > MAX_PASTE_LEN:
log.info("Full output is too long to upload")
return "too long to upload"
-
- url = URLs.paste_service.format(key="documents")
- try:
- async with self.bot.http_session.post(url, data=output, raise_for_status=True) as resp:
- data = await resp.json()
-
- if "key" in data:
- return URLs.paste_service.format(key=data["key"])
- except Exception:
- # 400 (Bad Request) means there are too many characters
- log.exception("Failed to upload full output to paste service!")
+ return await send_to_paste_service(self.bot.http_session, output, extension="txt")
@staticmethod
def prepare_input(code: str) -> str: