-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
41 lines (31 loc) · 996 Bytes
/
index.ts
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
if (process.env.NODE_ENV != 'production') {
require('dotenv').config();
console.log('Dev mode');
}
import Discord from 'discord.js';
import EventController from './controllers/EventController';
import fs from 'fs/promises';
import ClientController from './controllers/ClientController';
ClientController.client = new Discord.Client();
let client = ClientController.client;
(async () => {
// Loading all command and effect files so that decorators get executed
await loadSideEffects();
// Adding the events to the discord client
for (let event of EventController.events) {
client.on(event.name, event.exec);
}
})();
async function loadSideEffects() {
let files = await fs.readdir('./events');
for (let file of files) {
require(`./events/${file}`);
}
files = await fs.readdir('./commands');
for (let file of files) {
require(`./commands/${file}`);
}
}
client.on('error', e => console.error(e));
client.on('warn', e => console.warn(e));
client.login(process.env.TOKEN);