-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
75 lines (63 loc) · 2.04 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
const { warn, error, debug } = require("./controllers/logger");
const { Client, Collection } = require("discord.js");
const { version } = require('./package.json');
const { readdirSync } = require("fs");
const { join } = require("path");
if (process.version.slice(1).split(".")[0] < 16) {
error(`Please update to Node 16 or higher.`);
process.exit(1);
}
/**
* The Discord client instance
* @typedef {Bot} Bot
* @extends {Client}
*/
class Bot extends Client {
constructor() {
super({
intents: 32767
});
const locales = [];
readdirSync(join(__dirname, 'locales'))
.filter(file => file.endsWith('.json'))
.forEach((file) => {
locales.push(file.replace('.json', ''))
});
this.commands = new Collection();
debug(`Successfully loaded ${locales.length} locales`);
this.slashCommands = new Collection();
this.config = require('./config/config.json');
debug(`Successfully loaded config`);
this.languages = require('i18n');
debug(`Successfully loaded languages`);
this.languages.configure({
locales: locales,
directory: join(__dirname, 'locales'),
defaultLocale: 'en',
retryInDefaultLocale: true,
objectNotation: true,
register: global,
logWarnFn: function(msg) {
warn(msg);
},
logErrorFn: function(msg) {
error(msg);
},
missingKeyFn: function(locale, key) {
return key;
},
mustacheConfig: {
tags: ["{{", "}}"],
disable: false
}
});
this.languages.setLocale(this.config.LANGUAGE);
debug(`Successfully set language to ${this.config.LANGUAGE}`);
this.version = version;
}
};
const client = new Bot();
module.exports = client;
// Initializing the project
require("./handler")(client);
client.login(client.config.TOKEN);