-
Notifications
You must be signed in to change notification settings - Fork 2
/
init.mjs
52 lines (45 loc) · 1.27 KB
/
init.mjs
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
import { fileURLToPath } from 'url';
import { dirname } from 'path';
import { execSync } from 'child_process';
import { existsSync } from 'fs';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
function updateBot() {
const repoUrl = 'https://github.com/Burhanverse/Tunified';
const localDir = __dirname;
try {
if (existsSync(`${localDir}/.git`)) {
console.log('Pulling latest changes...');
execSync('git pull', { cwd: localDir });
} else {
console.log('Cloning the repository...');
execSync(`git clone ${repoUrl} ${localDir}`);
}
console.log('Update complete!');
} catch (error) {
console.error('Error updating bot files:', error.message);
}
}
function updateModules() {
try {
console.log('Updating Node modules...');
execSync('npm ci', { cwd: __dirname, stdio: 'inherit' });
console.log('Modules updated!');
} catch (error) {
console.error('Error updating Node modules:', error.message);
}
}
function startBot() {
try {
console.log('Starting bot...');
execSync('node bot.mjs', { stdio: 'inherit' });
} catch (error) {
console.error('Error starting the bot:', error.message);
}
}
function main() {
updateBot();
updateModules();
startBot();
}
main();