From 6a0596d3a4371a422853afb92f6c512836b7b45e Mon Sep 17 00:00:00 2001 From: Bsian Date: Mon, 4 May 2020 00:46:51 +0100 Subject: [PATCH] Fix too long error --- src/commands/pull.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/commands/pull.ts b/src/commands/pull.ts index 8ab1183..4cdcb3b 100644 --- a/src/commands/pull.ts +++ b/src/commands/pull.ts @@ -1,4 +1,5 @@ import { Message } from 'eris'; +import axios from 'axios'; import { Client } from '..'; import { Command } from '../class'; @@ -68,8 +69,21 @@ export default class Pull extends Command { try { build = await this.client.util.exec('yarn run build', { cwd: '/opt/CloudServices' }); } catch (error) { - const updatedMessage = updatedPackages.content.replace(`${this.client.stores.emojis.loading} ***Rebuilding files...***`, `${this.client.stores.emojis.error} ***Failed to rebuild files***\n` - + `\`\`\`\n${error.message}\n\`\`\``); + let updatedMessage = updatedPackages.content.replace(`${this.client.stores.emojis.loading} ***Rebuilding files...***`, `${this.client.stores.emojis.error} ***Failed to rebuild files***\n`); + if (error.message.length < 1800) updatedMessage += `\`\`\`\n${error.message}\n\`\`\``; + else { + const split = this.client.util.splitString(error.message, 1975); + if (split[5]) { + try { + const { data } = await axios.post('https://snippets.cloud.libraryofcode.org/documents', split.join('')); + updatedMessage += `${this.client.stores.emojis.success} The error output can be found on https://snippets.cloud.libraryofcode.org/${data.key}`; + } catch (e) { + updatedMessage += `${this.client.stores.emojis.error} Could not upload error: ${e}`; + } + } else { + split.forEach((m) => message.channel.createMessage(`\`\`\`bash\n${m}\n\`\`\``)); + } + } this.client.buildError = true; this.client.updating = false; return updateMessage.edit(updatedMessage);