forked from funnbot/Nitro
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheval.js
More file actions
60 lines (54 loc) · 1.55 KB
/
Copy patheval.js
File metadata and controls
60 lines (54 loc) · 1.55 KB
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
const util = require('util');
const config = require("../config.js")
const r = require("rethinkdbdash")({
db: "Nitro",
password: config.rethink
})
exports.run = async(message, bot, send) => {
if (message.author.id !== "163735744995655680") return
if (message.suffix.length < 1) {
let txt = evalTxt("Funnbot", "Output", "100000", "An idiot who does not provide code when he evals.")
return send(txt)
}
let processtime,
start = (new Date()).getTime()
try {
let evaled = await eval(message.suffix)
processtime = (new Date()).getTime() - start
if (typeof evaled === "object" || typeof evaled === "function") evaled = util.inspect(evaled)
if (typeof evaled === "string") evaled = evaled.substring(0, 1800).replace("`", "")
let txt = evalTxt(message.suffix, "Output", processtime, evaled)
txt = clean(txt)
return send(txt)
} catch (e) {
processtime = (new Date()).getTime() - start
let txt = evalTxt(message.suffix, "Error", processtime, e)
txt = clean(txt)
return send(txt)
}
}
let evalTxt = (a, b, c, d) => {
return `
:inbox_tray: **Input:**
\`\`\`js
${a}\`\`\`
:outbox_tray: **${b}:**
\`\`\`${b === "Output" ? "js" : "prolog"}
${d}\`\`\`
\`Execution Time: ${c}MS\``
}
let clean = (t) => {
let split = config.token.split(".")
let r = new RegExp(`(${split[1]})|(${split[2]})`, "g")
t = t.toString().replace(r, "[SECRET]")
return t
}
exports.conf = {
userPerm: ["DEV"],
botPerm: ["SEND_MESSAGES"],
coolDown: 0,
dm: true,
category: "DevOnly",
help: "Eval a bit o code",
args: "<code>"
}