const http = require('http'); const { exec } = require('child_process'); // Create HTTP server http.createServer((req, res) => { res.writeHead(200, {'Content-Type': 'text/html'}); res.end('KING Haki'); }).listen(7860, () => { console.log('Server listening on port 7860'); }); // Function to restart the bot function restartBot() { console.log("Restarting bot..."); exec("pm2 restart bot", (error, stdout, stderr) => { if (error) { console.error(`Error while restarting the bot: ${error.message}`); return; } if (stderr) { console.error(`Stderr: ${stderr}`); return; } console.log(`Bot restarted successfully: ${stdout}`); }); } // Set an interval to restart the bot every 5 hours (5 * 60 * 60 * 1000 = 18000000 ms) setInterval(restartBot, 18000000);