-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
27 lines (22 loc) · 891 Bytes
/
bot.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
'use strict';
const configFile = require('./config.json');
const client = new (require('discord.js')).Client();
const MessageHandler = require('./src/messageHandler.js');
const modulesPath = require('path').join(__dirname, './src/modules');
const messageHandler = new MessageHandler(client);
require('fs').readdirSync(modulesPath).forEach(function (file) {
let moduleSplit = file.split('.');
if (moduleSplit[1] !== 'js') {
return;
}
let configObjekt = configFile[moduleSplit[0]];
let DiscordModule = require('./src/modules/' + file);
let newModule = new DiscordModule(client, configObjekt);
messageHandler.registerModule(newModule);
});
client.on('message', (message) => messageHandler.handleMessage(message));
client.login(configFile.discordToken).then(function (token) {
console.log('Connected.');
}).catch(function (error) {
console.log('Error: ' + error);
});