-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBootLoader.js
92 lines (85 loc) · 4.32 KB
/
BootLoader.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
const { version } = require("os");
const fs = require("fs");
module.exports = {
StartUpChecks: () => {
//Checks for required packages
try {
const { CommandoClient } = require("discord.js-commando");
const discord = require("discord.js");
const chalk = require("chalk");
const db = require("quick.db");
const ms = require("ms");
}catch(err) {
console.log(`
Missing packages have been detected. Please insure the following packages are installed:
npm i discord.js
npm i discord.js-commando
npm i quick.db
npm i chalk
npm i ms
`);
process.exit();
}
const chalk = require("chalk");
const db = require("quick.db");
//Checks for Token.js
try {
if (!fs.existsSync("./Token.js")) {
console.log(chalk.red("Token.js not found! Creating file!"));
fs.writeFileSync("Token.js", 'var Token = [\n key = "BOT TOKEN HERE",\n ApplicationLink = ""\n];', function (err) {
if (err) throw err;
console.log(chalk.redBright("There was an issue creating Token.js"));
});
console.log(chalk.green("Successfully created Token.js! Please fill in the file!"));
process.exit();
}
}catch(err) {
console.error(err);
}
//Checks if token is in place
const token = require("./Token.js");
if (key == ""){
console.log(chalk.red(`Please make sure there is a token in Token.js`));
process.exit();
};
//Checks for Configuration.js
try {
if (!fs.existsSync("./Configuration.js")) {
console.log(chalk.red("Fatal Error! Could not find Configuration.js"));
console.log(chalk.red("Configuration.js is a critical file and the bot will not work without it!"));
console.log(chalk.red("Please download the file and configure the file to start the bot!"));
console.log(chalk.green("Official Bot Website: https://github.com/theopcoder/HermitcraftBot/tree/master"));
process.exit();
}
}catch(err) {
console.error(err);
}
//Checks for System.js
try {
if (!fs.existsSync("./System.js")) {
console.log(chalk.red("Fatal Error! Could not find System.js"));
console.log(chalk.red("System.js is a critical file containing error codes and information for the bot!"));
console.log(chalk.red("Please re add this file from the link below to start the bot!"));
console.log(chalk.green("Official Bot Website: https://github.com/theopcoder/HermitcraftBot/tree/master"));
process.exit();
}
}catch(err) {
console.error(err);
}
//First Time SetUp Setting Defaults
//Settings
if (db.get("settings.LevelUpSystem")== null)db.set("settings.LevelUpSystem", 1);
if (db.get("settings.DeadChatPings")== null)db.set("settings.DeadChatPings", 1);
if (db.get("settings.AutoModeration")== null)db.set("settings.AutoModeration", 1);
if (db.get("settings.StaffApplications")== null)db.set("settings.StaffApplications", 0);
//Auto Moderation
if (db.get("AutoModeration.MuteBypassProtection")== null)db.set("AutoModeration.MuteBypassProtection", 1);
if (db.get("AutoModeration.ChatFilter")== null)db.set("AutoModeration.ChatFilter", 1);
if (db.get("AutoModeration.DiscordInviteChecker")== null)db.set("AutoModeration.DiscordInviteChecker", 1);
if (db.get("AutoModeration.EditedMessageLogger")== null)db.set("AutoModeration.EditedMessageLogger", 1);
if (db.get("AutoModeration.DeletedMessageLogger")== null)db.set("AutoModeration.DeletedMessageLogger", 1);
//
//Finish Message
console.log(chalk.greenBright("All Startup Checks Passed Successfully!"));
},
};