This repository was archived by the owner on Jun 16, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.js
More file actions
82 lines (71 loc) · 2.04 KB
/
Copy pathsetup.js
File metadata and controls
82 lines (71 loc) · 2.04 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const fs = require('fs');
const path = require('path');
const { exec } = require('child_process');
const dependencies = [
'discord.js@14.0.0',
'@discordjs/voice',
'@napi-rs/canvas',
'dotenv',
'undici',
'avconv',
'ffmpeg',
'ffmpeg-static',
'libsodium-wrappers',
];
const devDependencies = [
'nodemon',
];
const envContent = `TOKEN=your-production-bot-token
CLIENT_ID=your-production-client-id
DEVTOKEN=your-development-bot-token
DEVCLIENT_ID=your-development-client-id
`;
const configContent = `{
"dev": true
}
`;
// Function to execute a command
function execute(command, callback) {
exec(command, (error, stdout, stderr) => {
if (error) {
console.error(`Error executing command: ${command}`, error);
return;
}
if (stderr) {
console.error(`Error output: ${stderr}`);
}
if (stdout) {
console.log(stdout);
}
callback();
});
}
// Step 1: Install packages
console.log('Installing packages...');
execute(`npm install ${dependencies.join(' ')} --save`, () => {
execute(`npm install ${devDependencies.join(' ')} --save-dev`, () => {
console.log('Packages installed successfully.');
// Step 2: Create .env file
console.log('Creating .env file...');
fs.writeFileSync(path.join(__dirname, '.env'), envContent, { flag: 'wx' }, (err) => {
if (err) throw err;
console.log('.env file created successfully.');
});
// Step 3: Create config.json file
console.log('Creating config.json file...');
fs.writeFileSync(path.join(__dirname, '/src/config.json'), configContent, { flag: 'wx' }, (err) => {
if (err) throw err;
console.log('config.json file created successfully.');
});
// Step 4: Create /db directory
console.log('Creating /db directory...');
const dbDir = path.join(__dirname, 'db');
if (!fs.existsSync(dbDir)) {
fs.mkdirSync(dbDir);
console.log('/db directory created successfully.');
} else {
console.log('/db directory already exists.');
}
console.log('Setup completed successfully.');
});
});