Repository navigation
Expand file tree
/
Copy pathspawn-bots.js
More file actions
executable file
·68 lines (58 loc) · 1.55 KB
/
Copy pathspawn-bots.js
File metadata and controls
executable file
·68 lines (58 loc) · 1.55 KB
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
#!/bin/env node
/* eslint-disable no-undef */
const child_process = require("child_process");
const fs = require("fs-extra");
const Logger = require("@hyarcade/logger");
const GetAsset = require("@hyarcade/utils/FileHandling/GetAsset");
const BotExit = require("@hyarcade/events/BotExit");
const BotStart = require("@hyarcade/events/BotStart");
// eslint-disable-next-line no-undef
const args = process.argv;
/**
* @param {number} time
* @returns {Promise}
*/
function sleep(time) {
return new Promise(resolve => {
setTimeout(resolve, time);
});
}
/**
*
*/
async function main() {
Logger.name = "Bot-Manager";
Logger.emoji = "🤖";
try {
Logger.info("Bots starting...");
const ascii = await fs.readFile(GetAsset("hyarcade.ascii"));
Logger.info(ascii.toString());
if (args[2] == "test") {
arcade = child_process.fork("./systems/discord/ShardManager.js", ["bot", "test"], {
silent: false,
});
} else {
arcade = child_process.fork("./systems/discord/ShardManager.js", ["bot"], {
silent: false,
});
await sleep(5500);
mw = child_process.fork("./systems/discord/ShardManager.js", ["bot", "mw"], {
silent: false,
});
await sleep(5500);
await BotStart();
}
} catch (error) {
Logger.err(error.stack);
}
process.on("SIGINT", async signal => {
mw.removeAllListeners();
arcade.removeAllListeners();
await BotExit();
arcade.kill();
mw.kill();
Logger.log(`Exiting process with signal : ${signal}`);
process.exit(0);
});
}
main();