From 73ed3ef4d363f29f5833ccd3696e3841d66570cd Mon Sep 17 00:00:00 2001 From: Alee14 Date: Sat, 12 Aug 2017 14:02:47 -0400 Subject: Eval Command --- aleebot.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'aleebot.js') diff --git a/aleebot.js b/aleebot.js index b6a25e0..05334d8 100644 --- a/aleebot.js +++ b/aleebot.js @@ -266,12 +266,31 @@ commandProcessed = true; return; message.channel.sendMessage(args.join(" ")); message.delete(); - } - + if(command === 'eval'){ + if(message.author.id !== config.ownerID) return; + try { + const code = args.join(" "); + let evaled = eval(code); + + if (typeof evaled !== "string") + evaled = require("util").inspect(evaled); + + message.channel.send(clean(evaled), {code:"xl"}); + } catch (err) { + message.channel.send(`\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``); + } + } }); +const clean = text => { + if (typeof(text) === "string") + return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203)); + else + return text; +} + process.on('unhandledRejection', function(err, p) { console.log("[ERROR | UNCAUGHT PROMISE] " + err.stack); }); -- cgit v1.2.3