-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
56 lines (45 loc) · 1.47 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
console.log("-------------------------------------------")
console.log("|andreweathan's discord server backup tool|")
console.log("| R E W R I T E |")
console.log("-------------------------------------------")
console.log()
import { OpenDatabases } from "./sql.js"
import { BackupActive } from "./backup.js"
import Discord from "discord.js-selfbot-v13"
import readline from "readline-sync"
await import ("dotenv/config")
let token = process.env.TOKEN
if (token.length <= 0)
token = readline.question("Insert token > ");
let bot = new Discord.Client({
intents: Discord.Intents.ALL, /*[
1, // guilds
2, // members
4, // guild bans
256, // presences
512, // messages
32768, // message content
],*/
checkUpdate: false
});
import questions from "./questions.js"
questions(bot)
bot.login(token);
console.log("Logging in...")
let interrupted = false;
export async function SIGINT() {
if (!BackupActive) {
console.log("Quitting");
process.exit();
}
if (interrupted) process.exit();
interrupted = true;
let original = OpenDatabases.length
console.log("Caught interrupt signal, closing " + original + " open databases...")
for (let i = original - 1; i >= 0; i--) {
await OpenDatabases[i].Close().catch(e => console.log(`Failed to close database ${original - i}:`, e));
console.log(`${original - i} / ${original}`);
}
console.log("Done. If you want to resume your backup (if it hasn't finished yet), you can do so later!")
process.exit();
}