diff --git a/.gitignore b/.gitignore index d296706..4fb39a3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .env node_modules/ -package-lock.json \ No newline at end of file +package-lock.json +config.js \ No newline at end of file diff --git a/Commands/Bot/eval.js b/Commands/Bot/eval.js new file mode 100644 index 0000000..e44c917 --- /dev/null +++ b/Commands/Bot/eval.js @@ -0,0 +1,30 @@ +const Command = require("../../Structure/Command.js"); + +module.exports = class extends Command { + constructor(client) { + super(client, { + name: "eval", + description: "Eval a js code.", + category: "Bot", + enabled: true, + aliases: [], + cooldown: 3, + dmOnly: false, + }); + } + + async run(message, args, data) { + if (parseInt(message.author.id) !== parseInt(data.config.ownerID)) return message.chat.sendMessage("Vous n'avez pas la permission d'utiliser cette commande.") + let result = new Promise((resolve) => resolve(eval(args.join(` `)))); + + return result.then((output) => { + if (typeof output !== "string") { + output = require("util").inspect(output, { depth: 0 }); + } + message.chat.sendMessage(output) + }).catch((err) => { + err = err.toString(); + message.chat.sendMessage(err); + }); + } +} \ No newline at end of file diff --git a/README.md b/README.md index 3383683..6b0e005 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,9 @@ it means that the bot is ready to be used. 🎉 # Available commands ## Bot -- !ping: Return the bot ping +- !ping: Return the bot ping. +- !help: Return the bot commands list. +- !eval: Eval a JS code. ## Images diff --git a/config.js b/config.example.js similarity index 65% rename from config.js rename to config.example.js index 07fcac3..535b890 100644 --- a/config.js +++ b/config.example.js @@ -1,3 +1,4 @@ module.exports = { defaultPrefix: `!`, + ownerID: "XXXXXX" } \ No newline at end of file