-
Notifications
You must be signed in to change notification settings - Fork 30
/
index.js
44 lines (34 loc) · 1.15 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
require("dotenv").config();
const { Client, Collection } = require("discord.js");
const UrlsConfig = require("./database/models/UrlsConfig");
const fetchProjects = require("./fetchProjects");
const { timeout, disable_fetching } = require("./config.json");
const client = new Client({
disableEveryone: true,
});
(async () => {
await require("./database/connect")();
let pros = await UrlsConfig.find();
client.commands = new Collection();
client.aliases = new Collection();
client.projectsSize = 0;
client.projects = pros.map((p) => p.projectURL);
UrlsConfig.countDocuments({}, async (err, total) => {
client.projectsSize = total;
["command", "events"].forEach((handler) => {
require(`./handlers/${handler}`)(client);
});
await client.login(process.env.BOT_TOKEN);
if (!disable_fetching) fetchProjects(client.projects, client);
});
})();
// pinging
setInterval(async () => {
UrlsConfig.countDocuments({}, (err, total) => {
client.projectsSize = total;
client.user.setActivity(`${total} Project(s)`, {
type: "WATCHING",
});
});
if (!disable_fetching) fetchProjects(client.projects, client);
}, timeout);