From fe2e6562ee51b1a291b9d0754b965aaaf47d3899 Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Sat, 1 Jun 2024 13:53:51 -0600 Subject: [PATCH] hastebins unreliable --- src/modules/bot.js | 22 ++++++++++++++++------ src/modules/misc.js | 20 +++++++++++++------- src/modules/utility.js | 11 +++++++++-- 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/modules/bot.js b/src/modules/bot.js index 48317a8..9510e63 100644 --- a/src/modules/bot.js +++ b/src/modules/bot.js @@ -6,8 +6,6 @@ const child_process = require("child_process"); const {inspect} = require("util"); const {resolve} = require("path"); -const {hastebin} = require("../lib/utils.js"); - const guildSettings = require("../lib/guildSettings.js"); function spawn(args) { @@ -107,8 +105,15 @@ _eval.callback = async function (msg, line) { return ":warning: Output (errored):\n```js\n" + out + "\n```"; } else { if (out.toString().length > 1980) { - const haste = await hastebin(out.toString()); - return `\u2705 Output too long to send in a message: ${haste}`; + return { + content: `\u2705 Output too long to send in a message:`, + attachments: [ + { + file: out, + filename: "message.txt", + }, + ], + }; } else { return "\u2705 Output:\n```js\n" + out + "\n```"; } @@ -135,9 +140,14 @@ exec.callback = async function (msg, line) { code != 0 ? "\x1b[31m" : "" }Exited with ${code}\x1b[0m`; if (out.length > 1980) { - const haste = await hastebin(out); msg.channel.createMessage({ - content: `Output too long to send in a message: ${haste}`, + content: `Output too long to send in a message:`, + attachments: [ + { + file: out, + filename: "message.txt", + }, + ], allowedMentions: { repliedUser: false, }, diff --git a/src/modules/misc.js b/src/modules/misc.js index 60ae45c..4088f3d 100644 --- a/src/modules/misc.js +++ b/src/modules/misc.js @@ -9,7 +9,6 @@ const {librex} = require("../../config.json"); const {getOption} = require("../lib/interactionDispatcher.js"); const { formatTime, - hastebin, parseHtmlEntities, formatUsername, safeString, @@ -177,15 +176,22 @@ wolfram.callback = async function (msg, line, args, {verbose, v}) { if (data[1].subpods[0].plaintext.length > 0) string = safeString(data[1].subpods[0].plaintext); - if (string.length > 2000 - (6 + safeString(query).length)) - string = "Output too long: " + (await hastebin(string)); + let text; + if (string.length > 2000 - (6 + safeString(query).length)) text = string; + string = "Output too long:"; return { content: `\`${safeString(query)}\` -> ${string.length > 0 ? string : ""}`, - file: image && { - file: image, - name: "wolfram_output.gif", - }, + attachments: [ + text && { + file: text, + filename: "message.txt", + }, + image && { + file: image, + filename: "wolfram_output.gif", + }, + ].filter((x) => !!x), }; } }; diff --git a/src/modules/utility.js b/src/modules/utility.js index 550f423..62aec2c 100644 --- a/src/modules/utility.js +++ b/src/modules/utility.js @@ -10,7 +10,6 @@ const {Constants, VoiceChannel} = require("@projectdysnomia/dysnomia"); const {getOption} = require("../lib/interactionDispatcher.js"); const { formatTime, - hastebin, lookupUser, formatUsername, safeString, @@ -1291,7 +1290,15 @@ charinfo.callback = async function (msg, line) { .join("\n"); if (lines.length > 2000) { - return "Output too long: " + (await hastebin(lines)); + return { + content: "Output too long:", + attachments: [ + { + file: lines, + filename: "message.txt", + }, + ], + }; } else { return lines; }