-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
53 lines (41 loc) · 1.37 KB
/
app.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
if (Number(process.version.slice(1).split(".")[0]) < 8) throw new Error("Node 8.0.0 or higher is required. Update Node on your system.");
const { Client } = require('discord.js');
const { promisify } = require('util');
const readdir = promisify(require('fs').readdir);
const Enmap = require('enmap');
require('dotenv-flow').config();
const client = new Client({
disableEveryone: true,
messageCacheMaxSize: 500,
messageCacheLifetime: 120,
messageSweepInterval: 60
});
client.appdata = new Enmap({
name: "approveData",
fetchAll: false,
autoFetch: true,
cloneLevel: 'deep'
});
client.commands = new Enmap();
client.aliases = new Enmap();
client.logger = require('./utils/logger');
require('./utils/functions')(client);
const init = async () => {
const cmdFiles = await readdir('./commands/');
cmdFiles.forEach(f => {
if (!f.endsWith('.js')) return;
const response = client.loadCommand(f);
if (response) client.logger.log(response);
});
client.logger.log(`Loading a total of ${cmdFiles.length} commands.`);
const evtFiles = await readdir('./events/');
evtFiles.forEach(f => {
const evtName = f.split('.')[0];
client.logger.log(`Loading Event: ${evtName} 👌`);
const event = require(`./events/${f}`);
client.on(evtName, event.bind(null, client));
});
client.logger.log(`Loading a total of ${evtFiles.length} events.`);
client.login(process.env.TOKEN);
};
init();