forked from engineering/cloudservices
Diagnosis
parent
8cad4a87db
commit
f5ae4392be
|
@ -22,47 +22,67 @@ export default class Eval extends Command {
|
||||||
let evalString: string;
|
let evalString: string;
|
||||||
let evaled: any;
|
let evaled: any;
|
||||||
let depth = 0;
|
let depth = 0;
|
||||||
|
this.client.signale.note('Received');
|
||||||
|
|
||||||
if (args[0] && args[0].startsWith('-d')) {
|
if (args[0] && args[0].startsWith('-d')) {
|
||||||
|
this.client.signale.note('Depth flag');
|
||||||
depth = Number(args[0].replace('-d', ''));
|
depth = Number(args[0].replace('-d', ''));
|
||||||
if (!depth || depth < 0) depth = 0;
|
if (!depth || depth < 0) depth = 0;
|
||||||
|
this.client.signale.note('Depth set');
|
||||||
args.shift();
|
args.shift();
|
||||||
evalString = args.join(' ').trim();
|
evalString = args.join(' ').trim();
|
||||||
|
this.client.signale.note('Eval reconfigured');
|
||||||
}
|
}
|
||||||
if (args[0] === '-a' || args[0] === '-async') {
|
if (args[0] === '-a' || args[0] === '-async') {
|
||||||
|
this.client.signale.note('Async flag');
|
||||||
args.shift();
|
args.shift();
|
||||||
evalString = `(async () => { ${args.join(' ').trim()} })()`;
|
evalString = `(async () => { ${args.join(' ').trim()} })()`;
|
||||||
|
this.client.signale.note('Eval reconfigured');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.client.signale.note('Main');
|
||||||
try {
|
try {
|
||||||
evaled = await eval(evalString);
|
evaled = await eval(evalString);
|
||||||
|
this.client.signale.note('evaluated with success');
|
||||||
if (typeof evaled !== 'string') {
|
if (typeof evaled !== 'string') {
|
||||||
|
this.client.signale.note('Eval returned not a string');
|
||||||
evaled = inspect(evaled, { depth });
|
evaled = inspect(evaled, { depth });
|
||||||
|
this.client.signale.note('Inspected');
|
||||||
}
|
}
|
||||||
if (evaled === undefined) {
|
if (evaled === undefined) {
|
||||||
|
this.client.signale.note('Eval undefined');
|
||||||
evaled = 'undefined';
|
evaled = 'undefined';
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
this.client.signale.note('Error caught');
|
||||||
evaled = error.stack;
|
evaled = error.stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.client.signale.note('Eval finished');
|
||||||
evaled = evaled.replace(new RegExp(this.client.config.token, 'gi'), 'juul');
|
evaled = evaled.replace(new RegExp(this.client.config.token, 'gi'), 'juul');
|
||||||
evaled = evaled.replace(new RegExp(this.client.config.emailPass, 'gi'), 'juul');
|
evaled = evaled.replace(new RegExp(this.client.config.emailPass, 'gi'), 'juul');
|
||||||
evaled = evaled.replace(new RegExp(this.client.config.cloudflare, 'gi'), 'juul');
|
evaled = evaled.replace(new RegExp(this.client.config.cloudflare, 'gi'), 'juul');
|
||||||
|
this.client.signale.note('Masked');
|
||||||
|
|
||||||
|
|
||||||
const display = this.client.util.splitString(evaled, 1975);
|
const display = this.client.util.splitString(evaled, 1975);
|
||||||
|
this.client.signale.note('Split output');
|
||||||
if (display[5]) {
|
if (display[5]) {
|
||||||
|
this.client.signale.note('Output greater than 5 messages');
|
||||||
try {
|
try {
|
||||||
const { data } = await axios.post('https://snippets.cloud.libraryofcode.org/documents', display.join(''));
|
const { data } = await axios.post('https://snippets.cloud.libraryofcode.org/documents', display.join(''));
|
||||||
|
this.client.signale.note('Data sent');
|
||||||
return message.channel.createMessage(`${this.client.stores.emojis.success} Your evaluation evaled can be found on https://snippets.cloud.libraryofcode.org/${data.key}`);
|
return message.channel.createMessage(`${this.client.stores.emojis.success} Your evaluation evaled can be found on https://snippets.cloud.libraryofcode.org/${data.key}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
this.client.signale.note('Error posting');
|
||||||
return message.channel.createMessage(`${this.client.stores.emojis.error} ${error}`);
|
return message.channel.createMessage(`${this.client.stores.emojis.error} ${error}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.client.signale.note('Single message');
|
||||||
return display.forEach((m) => message.channel.createMessage(`\`\`\`js\n${m}\n\`\`\``));
|
return display.forEach((m) => message.channel.createMessage(`\`\`\`js\n${m}\n\`\`\``));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
this.client.signale.note('Global error caught');
|
||||||
return this.client.util.handleError(error, message, this);
|
return this.client.util.handleError(error, message, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue