JaBa/commands/Owner/eval.js

38 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const Command = require("../../base/Command.js");
class Eval extends Command {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-10 21:39:54 +05:00
super(client, {
name: "eval",
dirname: __dirname,
enabled: true,
guildOnly: false,
aliases: ["ev"],
2021-12-10 21:39:54 +05:00
memberPermissions: [],
2021-12-26 19:29:37 +05:00
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
2021-12-10 21:39:54 +05:00
nsfw: false,
ownerOnly: true,
cooldown: 2000
2021-12-10 21:39:54 +05:00
});
}
2021-12-26 19:29:37 +05:00
async run(message, args, data) {
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-26 19:29:37 +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");
2022-01-03 23:20:33 +05:00
message.channel.send({ content: "```js\n" + output + "```" });
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");
2022-01-03 23:20:33 +05:00
message.channel.send({ content: "```js\n" + err + "```" });
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;