-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
48 lines (37 loc) · 1.05 KB
/
index.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
39
40
41
42
43
44
45
46
47
48
// https://discordapp.com/oauth2/authorize?client_id=479944525943537665&scope=bot&permissions=268528647
const Discord = require('discord.js');
const auth = require("./auth.json");
const activationStrings = require("./activation-strings.js");
const actions = require("./actions.js");
const strings = require("./strings.js")
const client = new Discord.Client();
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
})
client.on('message', msg => {
let hasRanCommand = false;
activationStrings.forEach(str => {
const strLen = str.length;
if (msg.content.substr(0, strLen) === str) {
const command = msg.content.substr(strLen);
hasRanCommand = true;
if (!actions[command])
msg.reply(strings.unknownCommand);
try {
actions[command](msg);
} catch (e) {
msg.reply(strings.error);
console.error(e);
}
}
});
if (!hasRanCommand && msg.channel.type === "dm") {
try {
actions.directMessage(msg);
} catch (e) {
msg.reply(strings.error);
console.error(e);
}
}
});
client.login(auth.token);