-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.js
More file actions
41 lines (34 loc) · 1 KB
/
bot.js
File metadata and controls
41 lines (34 loc) · 1 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
"use strict";
let Discord = require(`discord.js`)
, BotHelper = require(`./helper`).BotHelper
, config = require(`./config`)
, bot = new Discord.Client()
;
bot.on(`ready`, () => {
console.info('Bot has started');
BotHelper.instance().updateStatus(bot);
});
bot.on(`message`, message => {
if (message.author.bot) {
return; // ignore messages from bots
}
if (!message.content) {
return; // maybe will be useful
}
if (message.content[0] !== config.commandPrefix) {
return; // ignore not command messages
}
let commandName = null
, params = []
;
if (message.content[1] !== config.commandPrefix) {
commandName = `account_info`;
params = message.content.substr(1).split(` `);
} else {
let parts = message.content.substr(2).split(` `);
commandName = parts[0];
params = parts.splice(1);
}
BotHelper.instance().handleCommand(commandName, params, message);
});
bot.login(config.botToken);