-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart-bot.js
67 lines (58 loc) · 1.98 KB
/
start-bot.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
console.clear();
const Discord = require("discord.js-selfbot-v13");
const config = require("./config.json");
const logger = require("./functions/logger.js");
const notify = require("./functions/notification.js");
const gitRepoIsUpToDate = require("git-repo-is-up-to-date");
const prompt = require("readline-sync");
const os = require("./functions/os.js");
require("dotenv").config();
const client = new Discord.Client({
patchVoice: true,
checkUpdate: false,
});
client.commands = new Discord.Collection();
client.events = new Discord.Collection();
client.prefix = config["Prefix"];
client.name = config["SelfBot Name"];
client.logger = logger;
client.dellist = null;
client.dellog = "";
client.automsg = [];
const handlers = ["command_handler", "event_handler"];
handlers.forEach((handler) => {
require(`./handlers/${handler}`)(client, Discord);
client.logger.debug(`Loaded ${handler}`);
});
client.logger.log("Logging in...");
client.on("ready", async () => {
console.clear();
client.logger.debug("Checking for update...");
const result = await gitRepoIsUpToDate();
if (!result) {
client.logger.warn(
"Bot is not update to date :C, Would you like to update?"
);
const prom = prompt.question("Y/n: ");
if (prom.toLowerCase() == "n") {
client.logger.log("Okay");
} else {
client.logger.log("Updating...");
os.execCommand("npm run update")
.then((res) => {
client.logger.success("Finished updating. Please re-run");
process.exit();
})
.catch((err) => {
console.log("os >>>", err);
});
}
} else {
client.logger.success("Up to date :D");
}
notify(`Bot is loaded. Logged in as ${client.user.username}`);
client.logger.success(
`${client.name} is loaded. Logged in as ${client.user.username}`
);
});
client.login(process.env.TOKEN);