-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommands.js
More file actions
27 lines (25 loc) · 729 Bytes
/
commands.js
File metadata and controls
27 lines (25 loc) · 729 Bytes
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
const clubbot = require("./commands/clubbot.js");
const commands = { clubbot };
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);
let command = "";
if (tokens) {
command = tokens.shift();
}
if (command.charAt(0) === "!") {
command = command.substring(1);
let server = "DM";
if (msg.guild) {
server = msg.guild.name;
}
if (command in commands) {
console.log(command, tokens, msg.author.username, "@", server);
commands[command](msg, tokens);
}
}
}
};