summaryrefslogtreecommitdiff
path: root/commands/eval.js
blob: a2cdbb46d4faf4c0c6522ced5787ed7f507033ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const Discord = require('discord.js');
exports.run = (client, message, args, config) => {
if(message.author.id !== config.ownerID) return;
const clean = text => {
  if (typeof(text) === "string")
    return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203));
  else
      return text;
}
const argseval = message.content.split(" ").slice(1);
  try {
    var code = argseval.join(" ");
    var evaled = eval(code);

    if (typeof evaled !== "string")
      evaled = require("util").inspect(evaled);
    message.delete();

    message.channel.send({
      embed: {
        color: 3191350,
        author: {
          name: "Eval is working!",
          icon_url: message.author.displayAvatarURL
        },
        fields: [{
            name: '**:inbox_tray: Input**',
            value: `\`\`\`js\n${code}\n\`\`\``
          },
          {
            name: '**:outbox_tray: Output**',
            value: `\`\`\`js\n${clean(evaled)}\n\`\`\``
          }
        ],
      }
    })
  } catch (err) {
    message.delete();

    message.channel.send({
      embed: {
        color: 3191350,
        author: {
          name: "Error",
          icon_url: message.author.displayAvatarURL
        },
        fields: [{
            name: '**Please check your code.**',
            value: `\`\`\`xl\n${clean(err)}\n\`\`\``
          },
          {
            name: '**Output**',
            value: `\`\`\`js\n${clean(evaled)}\n\`\`\``
					}
				],
			}
		})
	}
}

exports.conf = {
  enabled: true,

  guildOnly: false,

  aliases: [],

  permLevel: 0

};

exports.help = {

  name: 'eval',

  description: 'It injects code but you cannot use it only the person host it is allow!',

  usage: 'eval [code]'

};