2020-10-21 07:06:52 +00:00
|
|
|
module.exports = class {
|
|
|
|
constructor (name, category) {
|
|
|
|
this.name = name,
|
|
|
|
this.category = category,
|
|
|
|
this.enabled = true,
|
|
|
|
this.devOnly = true,
|
|
|
|
this.aliases = [],
|
|
|
|
this.userPerms = [],
|
|
|
|
this.botPerms = [],
|
|
|
|
this.cooldown = 0,
|
|
|
|
this.help = {
|
|
|
|
description: 'Evalutes and executes JavaScript code.',
|
2020-10-29 08:20:45 +00:00
|
|
|
arguments: '<code>',
|
|
|
|
details: '',
|
2020-10-21 07:06:52 +00:00
|
|
|
examples: 'eval this.client.deleteCapitalism()'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
async run (client, message, args, data) { //eslint-disable-line no-unused-vars
|
|
|
|
const code = args.join(' ');
|
|
|
|
try {
|
|
|
|
const evaled = eval(code);
|
2020-10-25 02:10:05 +00:00
|
|
|
const clean = await client.functions.clean(evaled);
|
2020-10-21 07:06:52 +00:00
|
|
|
const MAX_CHARS = 3 + 2 + clean.length + 3;
|
|
|
|
if (MAX_CHARS > 2000) {
|
2020-10-25 02:10:05 +00:00
|
|
|
return message.channel.createMessage(undefined, { file: Buffer.from(clean), name: 'EVAL_SUCCESS.js' });
|
2020-10-21 07:06:52 +00:00
|
|
|
}
|
|
|
|
message.channel.createMessage(`\`\`\`js\n${clean}\n\`\`\``);
|
|
|
|
} catch (err) {
|
2020-10-25 02:10:05 +00:00
|
|
|
const e = await client.functions.clean(err);
|
2020-10-21 07:06:52 +00:00
|
|
|
const MAX_CHARS = 3 + 2 + e.length + 3;
|
|
|
|
if (MAX_CHARS > 2000) {
|
|
|
|
return message.channel.createMessage(undefined, { file: Buffer.from(e), name: 'EVAL_ERROR.txt' });
|
|
|
|
}
|
|
|
|
|
|
|
|
message.channel.createMessage(`\`\`\`xl\n${e}\n\`\`\``);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|