-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.js
More file actions
42 lines (34 loc) · 1.03 KB
/
bot.js
File metadata and controls
42 lines (34 loc) · 1.03 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
42
'use strict';
let Discord = require(`discord.js`)
, BotHelper = require(`./bot-helper`)
, ConfigProvider = require(`./config/provider`)
, bot = new Discord.Client()
;
bot.on(`ready`, () => {
console.info('Bot has started');
const username = ConfigProvider.get(`username`);
BotHelper.updateVotingPowerStatus(bot, username);
setInterval(
function() {
BotHelper.updateVotingPowerStatus(bot, username);
},
1000 * 60 // every 1 minute
);
});
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] !== ConfigProvider.get(`commandPrefix`)) {
return; // ignore not command messages
}
let parts = message.content.substr(1).trim().split(` `)
, command = parts[0]
, params = parts.splice(1)
;
BotHelper.handleBotCommand(command, params, message);
});
bot.login(ConfigProvider.get(`botToken`));