From b1c94508136a7a09019b77892c174d1eaa85325a Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Sun, 24 Mar 2024 04:00:59 -0600 Subject: [PATCH] Guh --- index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 856394b..f28a451 100644 --- a/index.js +++ b/index.js @@ -1169,7 +1169,19 @@ dcClient.on('interactionCreate', async interaction => { stream.on('exit', (code, signal) => { console.log(`Ran command ${cmd}:\n${outputStream}`) console.log("TEST" + outputStream.length) - interaction.editReply(`Ran command ${cmd}:\n\`\`\`ansi\n${outputStream}\n\`\`\``); + // generate message json + const msgJson = { + content: `Ran command \`${cmd}\`\n\`\`\`ansi\n${outputStream}\`\`\`` + } + // outputStream is too long for Discord, so we need to send it as a file + if (outputStream.length > 2000) { + // make the buffer + const buffer = Buffer.from(outputStream, 'utf-8'); + const attachment = new Discord.MessageAttachment(buffer, 'output.txt'); + msgJson.files = [attachment]; + msgJson.content = `Ran command \`${cmd}\`\nOutput too long, sending as a file` + } + interaction.editReply(msgJson); sendLog(`${colors.green("[INFO]")} Ran command ${cmd}`); }); });