-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix.js
More file actions
102 lines (86 loc) · 3.55 KB
/
Copy pathfix.js
File metadata and controls
102 lines (86 loc) · 3.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env node
// Botrix Quick Fix Script
// Run with: node fix.js
const fs = require('fs');
const path = require('path');
console.log('🔧 Botrix Quick Fix Tool');
console.log('========================\n');
// Fix 1: Ensure config directory exists
console.log('🔧 Fix 1: Creating config directory');
const configDir = path.join(__dirname, 'config');
if (!fs.existsSync(configDir)) {
fs.mkdirSync(configDir, { recursive: true });
console.log(' ✅ Created config directory');
} else {
console.log(' ✅ Config directory exists');
}
// Fix 2: Create test bot config if missing
console.log('\n🔧 Fix 2: Creating test bot configuration');
const testBotDir = path.join(configDir, 'test-bot');
const testBotEnv = path.join(testBotDir, '.env');
if (!fs.existsSync(testBotDir)) {
fs.mkdirSync(testBotDir, { recursive: true });
}
if (!fs.existsSync(testBotEnv)) {
const envContent = `# Discord Bot Token - Replace with your actual bot token
DISCORD_TOKEN=YOUR_BOT_TOKEN_HERE
# Bot Configuration
BOT_PREFIX=!
BOT_NAME=My Test Bot`;
fs.writeFileSync(testBotEnv, envContent);
console.log(' ✅ Created test bot configuration');
console.log(' ⚠️ Remember to replace YOUR_BOT_TOKEN_HERE with your actual bot token');
} else {
console.log(' ✅ Test bot configuration exists');
}
// Fix 3: Check package.json for issues
console.log('\n🔧 Fix 3: Checking package.json');
try {
const package = require('./package.json');
const requiredDeps = ['discord.js', 'electron', 'dotenv', 'express'];
for (const dep of requiredDeps) {
if (!package.dependencies[dep]) {
console.log(` ❌ Missing dependency: ${dep}`);
} else {
console.log(` ✅ Found dependency: ${dep}`);
}
}
} catch (error) {
console.log(` ❌ Error reading package.json: ${error.message}`);
}
// Fix 4: Create basic .env if missing
console.log('\n🔧 Fix 4: Checking root .env file');
const rootEnv = path.join(__dirname, '.env');
if (!fs.existsSync(rootEnv)) {
const envContent = `# Discord OAuth Configuration
DISCORD_CLIENT_ID=your_client_id
DISCORD_CLIENT_SECRET=your_client_secret
DISCORD_REDIRECT_URI=http://localhost:3000/oauth/callback
DISCORD_SCOPES=identify
OAUTH_STATE_SECRET=your_random_secret_here`;
fs.writeFileSync(rootEnv, envContent);
console.log(' ✅ Created root .env file');
console.log(' ⚠️ Remember to add your Discord OAuth credentials');
} else {
console.log(' ✅ Root .env file exists');
}
// Fix 5: Check for common file issues
console.log('\n🔧 Fix 5: Checking core files');
const coreFiles = ['main.js', 'bot.js', 'preload.js', 'renderer.js', 'index.html', 'styles.css'];
for (const file of coreFiles) {
if (fs.existsSync(path.join(__dirname, file))) {
console.log(` ✅ Found: ${file}`);
} else {
console.log(` ❌ Missing: ${file}`);
}
}
console.log('\n🎯 Quick Fix Complete!');
console.log('\n📋 Next Steps:');
console.log('1. Run: npm install');
console.log('2. Get your Discord bot token from https://discord.com/developers/applications');
console.log('3. Replace YOUR_BOT_TOKEN_HERE in config/test-bot/.env');
console.log('4. Invite your bot to a Discord server');
console.log('5. Run: npm run diagnose (to test everything)');
console.log('6. Run: npm start (to launch Botrix)');
console.log('\n📖 For detailed help, check TROUBLESHOOTING.md');
console.log('🔗 Discord Developer Portal: https://discord.com/developers/applications');