-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcommands.js
38 lines (33 loc) · 1.07 KB
/
commands.js
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
const gif = require("./commands/gif.js");
const help = require("./commands/help.js");
const tbr = require("./commands/tbr.js");
const count = require("./commands/count.js");
const tags = require("./commands/tags.js");
const commands = { gif, help, tbr, count, tags };
module.exports = async function (msg) {
let tokens = msg.content;
if (tokens.length > 0) {
tokens = tokens.replace(/["“”]+/g, '"');
tokens = tokens.replace(/[,]+/g, " ");
tokens = tokens.match(/(?:[^\s"]+|"[^"]*")+/g);
if (!tokens) {
return;
}
const firstWord = tokens.shift();
if (firstWord.charAt(0) !== "!") {
return;
}
let server = "DM";
if (msg.guild) {
server = msg.guild.name;
}
const command = firstWord.substring(1);
if (command in commands) {
console.log(command, tokens, msg.author.username, "@", server);
commands[command](msg, tokens);
} else if (command.toLowerCase().includes("allenbot")) {
console.log(command, tokens.join(" "), msg.author.username, "@", server);
commands["gif"](msg, []);
}
}
};