forked from Guiz711/codefr_bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (32 loc) · 839 Bytes
/
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
const Discord = require('discord.js');
const client = new Discord.Client();
const dotenv = require("dotenv").config();
const botConfig = require('./json_resources/bot_config.json');
const CmdHandler = require('./CmdHandler.js');
const logger = require("./libs/logger");
/*
** Bot initialization and events handling.
*/
CmdHandler.setVerbose();
const handler = new CmdHandler('commands');
handler.loadAllCommands();
client.on('ready', () =>
logger.info('Discord bot ready')
);
client.on('error', err =>
logger.err(err)
);
client.on('message', msg => {
try {
handler.treatMessage(client, msg);
} catch (err) {
logger.err(err.message);
}
});
/**
* bot_token.json content:
* {
* "T": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
* }
*/
client.login(process.env.BOT_TOKEN);