diff options
| author | Unknown <jtsshieh@outlook.com> | 2018-02-24 15:08:05 -0500 |
|---|---|---|
| committer | Unknown <jtsshieh@outlook.com> | 2018-02-24 15:08:05 -0500 |
| commit | 448d794372baa5535f6886e5b47344e6130dc8a7 (patch) | |
| tree | 9060e55f976eefff6fc840271ede68bf4b1539ad /commands/Owners Only | |
| parent | c484753ee15dbe2a5ce9c6297f22fabb52ce3b7e (diff) | |
| download | PokeBot-448d794372baa5535f6886e5b47344e6130dc8a7.tar.gz PokeBot-448d794372baa5535f6886e5b47344e6130dc8a7.tar.bz2 PokeBot-448d794372baa5535f6886e5b47344e6130dc8a7.zip | |
eval
Diffstat (limited to 'commands/Owners Only')
| -rw-r--r-- | commands/Owners Only/eval.js | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/commands/Owners Only/eval.js b/commands/Owners Only/eval.js new file mode 100644 index 0000000..1e7bb4e --- /dev/null +++ b/commands/Owners Only/eval.js @@ -0,0 +1,67 @@ +exports.run = async (bot, msg, args) => { + if (!['242775871059001344', '247221105515823104', '236279900728721409'].includes(msg.author.id)) { + msg.reply('Nope! You need the person who created this bot to use this command.'); + } + const code = args.join(' '); + + let evaled; + let remove; + + try { + 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 bot.Embed() + .setAuthor('Eval Error') + .setDescription('Eval\'s result') + .addField(':inbox_tray: Input:', `\`\`\`js\n${code}\n\`\`\``) + .addField(':outbox_tray: Output:', `\`\`\`${err.stack}\`\`\``) + .setFooter('Eval', bot.user.avatarURL) + .setColor('RED'); + return msg.channel.send({ embed }); + } + + try { + const embed = new bot.Embed() + .setAuthor('Eval Success') + .setDescription('Eval\'s result') + .addField(':inbox_tray: Input:', `\`\`\`js\n${code}\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 bot.Embed() + .setAuthor('Eval Error') + .setDescription('Eval\'s result') + .addField(':inbox_tray: Input:', `\`\`\`js\n${code}\n\`\`\``) + .addField(':outbox_tray: Output:', `\`\`\`${err.stack}\`\`\``) + .setFooter('Eval', bot.user.avatarURL) + .setColor('RED'); + return msg.channel.send({ embed }); + } +}; + +exports.conf = { + aliases: [], + guildOnly: false, +}; + +exports.help = { + name: 'eval', + description: 'Evaluates Javascript Code', + usage: '<code>', +}; |
