woomy-v2/bot/commands/Developer/eval.js

37 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-08-18 04:58:36 +00:00
const Command = require("../../base/Command.js");
const Discord = require("discord.js");
class Eval extends Command {
constructor (client) {
super(client, {
description: "Evaluates arbitrary Javascript.",
usage: "eval <expression>",
aliases: ["ev"],
permLevel: "Bot Owner",
devOnly: true
});
}
async run (message, args, data) { // eslint-disable-line no-unused-vars
const code = args.join(" ");
try {
const evaled = eval(code);
2020-10-08 02:05:14 +00:00
const clean = await this.client.functions.clean(evaled);
2020-08-18 04:58:36 +00:00
const MAX_CHARS = 3 + 2 + clean.length + 3;
if (MAX_CHARS > 2000) {
message.channel.send({ files: [new Discord.MessageAttachment(Buffer.from(clean), "output.txt")] });
}
message.channel.send(`\`\`\`js\n${clean}\n\`\`\``);
} catch (err) {
2020-10-08 02:05:14 +00:00
const e = await this.client.functions.clean(err);
2020-08-18 04:58:36 +00:00
const MAX_CHARS = 1 + 5 + 1 + 3 + e.length + 3;
if (MAX_CHARS > 2000) {
return message.channel.send({ files: [new Discord.MessageAttachment(Buffer.from(e), "error.txt")] });
}
message.channel.send(`\`ERROR\` \`\`\`xl\n${e}\n\`\`\``);
}
}
}
module.exports = Eval;