Fix too long error

merge-requests/4/head
Bsian 2020-05-04 00:46:51 +01:00
parent 58989a9b7e
commit 6a0596d3a4
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
1 changed files with 16 additions and 2 deletions

View File

@ -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);