forked from Curnal/ControlPanel-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
66 lines (62 loc) · 1.58 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
const Discord = require("discord.js");
const fs = require("fs");
const Josh = require("josh");
const provider = require('@josh-providers/mongo');
require('moment-duration-format');
// Create client
const client = new Discord.Client({
ws: {
intents: [
'GUILD_MESSAGES',
'GUILDS',
'GUILD_MEMBERS',
'DIRECT_MESSAGES'
]
},
disableEveryone: true,
messageCacheMaxSize: 1,
messageCacheLifetime: 5,
messageSweepInterval: 30,
});
// Global variables
client.config = require('./config.js');
client.modules = [ "general", "panel", "billing", "staff", "owner" ];
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
client.serverDB = new Josh({
name: 'servers',
provider,
providerOptions: {
collection: 'servers',
dbName: "PteroManager",
url: client.config.mongo
}
});
client.userDB = new Josh({
name: 'users',
provider,
providerOptions: {
collection: 'users',
dbName: "PteroManager",
url: client.config.mongo
}
});
// Load modules
fs.readdir(`${process.cwd()}/modules/`, (err, files) => {
if (err) { throw err }
for (const file of files) {
if (!file.endsWith(".js")) continue;
require(`${process.cwd()}/modules/${file}`)(client);
}
client.log("BOT", "Starting...");
client.log("BOT", "Loaded modules");
client.loadEvents();
client.loadCommands();
});
// Log into client
try {
client.login(client.config.token);
} catch(e) {
console.error(`Invalid token: ${e}`);
process.exit(2);
}