aboutsummaryrefslogtreecommitdiff
path: root/commands/Owners Only/eval.js
diff options
context:
space:
mode:
authorUnknown <jtsshieh@outlook.com>2018-03-13 17:24:39 -0400
committerUnknown <jtsshieh@outlook.com>2018-03-13 17:24:39 -0400
commit16a36e8271e98fc5e839cd374aa496309ddc540b (patch)
tree788411bd332e85185639ec8da3b0d18197418c9d /commands/Owners Only/eval.js
parenta264d43540a4f819684c13b162e2697b5897a09d (diff)
downloadPokeBot-16a36e8271e98fc5e839cd374aa496309ddc540b.tar.gz
PokeBot-16a36e8271e98fc5e839cd374aa496309ddc540b.tar.bz2
PokeBot-16a36e8271e98fc5e839cd374aa496309ddc540b.zip
revert
Diffstat (limited to 'commands/Owners Only/eval.js')
-rw-r--r--commands/Owners Only/eval.js41
1 files changed, 30 insertions, 11 deletions
diff --git a/commands/Owners Only/eval.js b/commands/Owners Only/eval.js
index 9db45bc..a6a6916 100644
--- a/commands/Owners Only/eval.js
+++ b/commands/Owners Only/eval.js
@@ -18,30 +18,49 @@
*
* *************************************/
-async function evaluate(code) {
- const str = `var func = async function() {\n ${code}\n}.bind(this)\nfunc`;
-
- const toExecute = eval(str);
-
- return await toExecute();
-}
exports.run = async (bot, msg, args) => {
if (!['242775871059001344', '247221105515823104', '236279900728721409'].includes(msg.author.id)) return msg.reply('Nope! You need the person who created this bot to use this command.');
const { RichEmbed } = require('discord.js');
const code = args.join(' ');
+ let evaled;
+ let remove;
+
try {
- const response = await evaluate(code);
- const util = require('util');
- const output = typeof response === 'string' || typeof response === 'number' ? response : util.inspect(response, { depth: 3 });
+ remove = text => {
+ if (typeof(text) === 'string') {
+ return text.replace(/`/g, '`' + String.fromCharCode(8203)).replace(/@/g, '@' + String.fromCharCode(8203));
+ } else {
+ return text;
+ }
+ };
+
+ evaled = eval(code);
+
+ if (typeof evaled !== 'string') {
+ evaled = require('util').inspect(evaled);
+ }
+
+ } catch (err) {
+ const embed = new RichEmbed()
+ .setAuthor('Eval Error')
+ .setDescription('Eval\'s result')
+ .addField(':inbox_tray: Input:', `\`\`\`js\n${code}\n\`\`\``)
+ .addField(':outbox_tray: Output:', `\`\`\`${err}\`\`\``)
+ .setFooter('Eval', bot.user.avatarURL)
+ .setColor('RED');
+ return msg.channel.send({ embed });
+ }
+ try {
const embed = new RichEmbed()
.setAuthor('Eval Success')
.setDescription('Eval\'s result')
.addField(':inbox_tray: Input:', `\`\`\`js\n${code}\n\`\`\``)
- .addField(':outbox_tray: Output:', `\`\`\`js\n${response}\n\`\`\``)
+ .addField(':outbox_tray: Output:', `\`\`\`js\n${remove(evaled)}\n\`\`\``)
.setFooter('Eval', bot.user.avatarURL)
.setColor('GREEN');
+
return msg.channel.send({ embed });
} catch (err) {
const embed = new RichEmbed()