-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
68 lines (47 loc) · 1.96 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
require("./helper/extenders");
const util = require("util")
const fs = require("fs")
const readdir = util.promisify(fs.readdir)
const mongoose = require("mongoose")
const kaktus = require("./main/kaktus"),
client = new kaktus();
const init = async () => {
const directories = await readdir("./commands/");
client.logger.log(`${directories.length} komut yükleniyor .`, "log");
directories.forEach(async (dir) => {
const commands = await readdir("./commands/" + dir + "/");
commands.filter((cmd) => cmd.split(".").pop() === "js").forEach((cmd) => {
const response = client.loadCommand("./commands/" + dir, cmd);
if (response) {
client.logger.log(response, "error");
}
});
});
const evtFiles = await readdir("./events/");
client.logger.log(`Toplam ${evtFiles.length} eventlar yükleniyor`, "log");
evtFiles.forEach((file) => {
const eventName = file.split(".")[0];
client.logger.log(`event Yükleniyor ${eventName}`);
const event = new (require(`./events/${file}`))(client);
client.on(eventName, (...args) => event.run(...args));
delete require.cache[require.resolve(`./events/${file}`)];
});
client.login(client.config.token);
mongoose.connect(client.config.mongoDB, { useNewUrlParser: true, useUnifiedTopology: true }).then(() => {
client.logger.log("veritabanına bağlandı.", "log");
}).catch((err) => {
client.logger.log("veritabanına bağlanılamıyor. Hatas:" + err, "error");
});
const languages = require("./helper/languages");
client.translations = await languages();
const autoUpdateDocs = require("./helper/autoUpdateDocs.js");
autoUpdateDocs.update(client);
};
init();
client.on("disconnect", () => client.logger.log("Bot bağlantısı kesiliyor...", "error"))
.on("reconnecting", () => client.logger.log("Bot yeniden bağlanıyor ...", "log"))
.on("error", (e) => client.logger.log(e, "error"))
.on("warn", (info) => client.logger.log(info, "warn"));
process.on("unhandledRejection", (err) => {
console.error(err);
});