-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhandler.js
More file actions
66 lines (53 loc) · 1.48 KB
/
handler.js
File metadata and controls
66 lines (53 loc) · 1.48 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
61
62
63
64
65
66
var Discord = require("discord.js");
var prune = require("./commands/prune");
var ready = require("./commands/ready");
var kick = require("./commands/kick");
var info = require("./commands/info");
var add = require("./commands/add");
function clean(text) {
if (typeof(text) === "string")
return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203));
else
return text;
}
module.exports = function (bot) {
bot.on("message", m => {
if (m.author !== bot.user) return;
global.m = m;
//set prefix
var p = ">+";
if (!m.content.startsWith(p)) return;
//args
global.args = m.content.split(" ").slice(1);
//commands
//prune
if (m.content.startsWith(p + "prune")) {
prune.delete();
}
//kick
if (m.content.startsWith(p + "kick")) {
kick.user();
}
//info
if (m.content.startsWith(p + "info")) {
info.bot();
}
//eval
if(m.content.startsWith(p + "eval")) {
try {
var code = args.join(" ");
var evaled = eval(code);
if (typeof evaled !== "string")
evaled = require("util").inspect(evaled);
m.channel.sendCode("xl", clean(evaled));
} catch(err) {
m.channel.sendMessage(`\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``);
console.log("Eval successfull");
}
}
//add
if(m.content.startsWith(p + "add")) {
add.math();
}
});
};