-
Notifications
You must be signed in to change notification settings - Fork 41
/
index.ts
67 lines (56 loc) · 2.63 KB
/
index.ts
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
import { Command } from "commander"
import fs from "node:fs"
import path from "node:path"
import { logger } from "./src/utils/logger.js"
import { Configuration, defaultConfig } from "./src/typings/typings.js"
import { BaseAgent } from "./src/structures/BaseAgent.js"
import { InquirerConfig } from "./src/structures/Inquirer.js"
const program = new Command()
const agent = new BaseAgent()
process.on("unhandledRejection", (error) => {
logger.error(error as Error)
logger.log("runtime", "Unhandled promise rejection")
}).on("uncaughtException", (error) => {
logger.error(error as Error)
logger.log("runtime", "Uncaught exception")
})
program
.name("BKI Advanced Discord OwO Selfbot")
.description("BKI Kyou Izumi Advanced Discord OwO Selfbot")
.version(JSON.parse(fs.readFileSync("./package.json", "utf-8")).version || "3.0.0")
program
.option("-g, --generate [filename]", "Generate new data file for autorun")
.option("-i, --import <filename>", "Import data file for autorun")
.option("-d, --debug", "Enable debug mode")
.action(async () => {
if (program.opts().debug) {
logger.logger.level = "debug"
logger.info("Debug mode enabled!")
}
if (program.opts()?.generate) {
const filename = typeof program.opts().generate === "string" ? program.opts().generate : "autorun.json"
if (fs.existsSync(filename) && fs.statSync(filename).size > 0) {
return logger.error(`File ${filename} already exists and is not empty!\nPlease remove it or specify another filename.`)
}
fs.writeFileSync(filename, JSON.stringify(defaultConfig, null, 4))
logger.info(`File generated: ${path.resolve(filename)}`)
return;
}
if (program.opts()?.import) {
if (!fs.existsSync(program.opts().import)) return logger.error(`File ${program.opts().import} does not exist!`)
if (path.extname(program.opts().import) !== ".json") return logger.error(`File ${program.opts().import} is not a JSON file!`)
const data = JSON.parse(fs.readFileSync(path.resolve(program.opts().import), "utf-8")) as Configuration
if (!data) return logger.error(`File ${program.opts().import} is empty!`)
try {
await agent.checkAccount(data.token);
agent.run(data)
} catch (error) {
logger.error(error as Error)
logger.error("Failed to import data file")
}
} else {
const config = await InquirerConfig(agent)
agent.run(config)
}
})
program.parse(process.argv)