JaBa/commands/Owner/eval.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const Command = require("../../base/Command.js");
class Eval extends Command {
constructor (client) {
super(client, {
name: "eval",
dirname: __dirname,
enabled: true,
guildOnly: false,
aliases: [],
memberPermissions: [],
botPermissions: [ "SEND_MESSAGES", "EMBED_LINKS" ],
nsfw: false,
ownerOnly: true,
cooldown: 2000
2021-12-10 21:39:54 +05:00
});
}
// eslint-disable-next-line no-unused-vars
async run (message, args, data) {
// eslint-disable-next-line no-unused-vars
const usersData = this.client.usersData;
// eslint-disable-next-line no-unused-vars
const guildsData = this.client.guildsData;
2021-12-11 01:11:50 +05:00
2021-12-10 21:39:54 +05:00
const content = message.content.split(" ").slice(1).join(" ");
const result = new Promise((resolve) => resolve(eval(content)));
2021-12-11 01:11:50 +05:00
2021-12-10 21:39:54 +05:00
return result.then((output) => {
2021-12-13 18:27:54 +05:00
if (typeof output != "string") output = require("util").inspect(output, { depth: 0 });
2021-12-11 01:11:50 +05:00
if (output.includes(this.client.token)) output = output.replace(this.client.token, "T0K3N");
message.channel.send(output, { code: "js" });
2021-12-10 21:39:54 +05:00
}).catch((err) => {
2021-12-13 18:27:54 +05:00
console.error(err);
2021-12-10 21:39:54 +05:00
err = err.toString();
2021-12-11 01:11:50 +05:00
if (err.includes(this.client.token)) err = err.replace(this.client.token, "T0K3N");
message.channel.send(err, { code: "js" });
2021-12-10 21:39:54 +05:00
});
}
2021-12-11 01:11:50 +05:00
};
2021-12-10 21:39:54 +05:00
module.exports = Eval;