-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
39 lines (35 loc) 路 1.1 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
const ui = require("./ui");
const auth = require("./auth");
const config = require("./config.json");
const discord = require("discord.js");
const commands = require("./commands");
const commandWarn = require("./commands/warn");
const commandWarnall = require("./commands/warnall");
const commandUnwarn = require("./commands/unwarn");
const bot = new discord.Client();
bot.on("ready", e => {
console.log("Connected", { username: bot.user.username, id: bot.user.id });
});
bot.on('message', async msg => {
try {
if (msg.content.startsWith(commands.commandPrefix(commandWarnall.command))) {
await commandWarnall.handle(msg, bot);
return;
}
if (msg.content.startsWith(commands.commandPrefix(commandWarn.command))) {
await commandWarn.handle(msg, bot);
return;
}
if (msg.content.startsWith(commands.commandPrefix(commandUnwarn.command))) {
await commandUnwarn.handle(msg, bot);
return;
}
else{
console.log(msg.content);
}
} catch (error) {
console.error("Error while handling message", error);
}
});
bot.login(auth.token);
ui.openBrowser();