forked from Weeb-Devs/Laffey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.js
46 lines (39 loc) · 2.19 KB
/
start.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
const chalk = require('chalk');
require('./src/modules/console');
const util = require('util');
const exec = util.promisify(require('child_process').exec);
let nodeVersionError = false;
let consoleIntro = "\n"+chalk.yellow('----------------------------------------------------------------------------------------------\n');
consoleIntro += chalk.cyan(
` ____ ____ ____ ____ ____ ____ ____ _________ ____ ____ ____ \n`+
`||G |||U |||N |||T |||H |||E |||R ||| |||B |||O |||T ||\n`+
`||__|||__|||__|||__|||__|||__|||__|||_______|||__|||__|||__||\n`+
`|/__\\|/__\\|/__\\|/__\\|/__\\|/__\\|/__\\|/_______\\|/__\\|/__\\|/__\\|\n\n`
);
consoleIntro += chalk.bold.cyan(`Version: ${require('./package.json').version}\n`);
consoleIntro += chalk.yellow('----------------------------------------------------------------------------------------------\n');
if (process.versions.node.split(".")[0] < 16) nodeVersionError = true;
if (process.versions.node.split(".")[0] >= 16 && process.versions.node.split(".")[1] < 9) nodeVersionError = true;
if (nodeVersionError) {
consoleIntro += chalk.red(`Outdated Node.js version. v16.9.0 or newer is required, you have ${process.version}\n`);
} else {
consoleIntro += chalk.dim('Found a bug? Feel free to create a new issue at https://github.com/Luisito3107/Gunther/issues/new\n');
consoleIntro += chalk.dim('⚠️ Make sure you have Node version 16.9.0 or newer, or you will get Object.hasOwn is not a function\n');
}
consoleIntro += chalk.cyan('----------------------------------------------------------------------------------------------\n');
console.log(consoleIntro);
delete consoleIntro;
if (!nodeVersionError) {
delete nodeVersionError;
const delay = ms => new Promise(resolve => setTimeout(resolve, ms))
async function startGunther() {
console.log(chalk.cyan("Starting Lavalink server..."))
await exec('pm2 start lavalink.js');
await delay(6000); // Time for the Lavalink server to start
console.log(chalk.cyan("Starting Gunther server..."))
let { stdout, stderr } = await exec('pm2 start gunther.js');
//console.log(stdout, stderr);
console.log(chalk.bold.green("Done!"))
}
startGunther();
}