From 75a1f6965597d44620d267c0e12b07f9c6841b07 Mon Sep 17 00:00:00 2001 From: Xargana Date: Sun, 30 Mar 2025 09:22:23 +0300 Subject: [PATCH] a --- discord/index.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/discord/index.js b/discord/index.js index 8daee33..12afad3 100644 --- a/discord/index.js +++ b/discord/index.js @@ -820,13 +820,16 @@ case "anime": const target = interaction.options.getString("target"); const maxHops = interaction.options.getInteger("hops") || 30; - const { exec } = require('child_process'); - exec(`tracepath -4 -m ${maxHops} ${target}`, async (error, stdout, stderr) => { - const output = stdout || stderr || 'No response'; - + const { spawn } = require('child_process'); + const traceroute = spawn('traceroute', ['-m', maxHops, target]); + + let output = ''; + + traceroute.stdout.on('data', async (data) => { + output += data.toString(); const traceEmbed = { - title: "Traceroute Results", - description: `Target: ${target}\nMax Hops: ${maxHops}\n\`\`\`${output}\`\`\``, + title: "Traceroute Results (Live)", + description: `Target: ${target}\nMax Hops: ${maxHops}\n\n\`\`\`\n${output}\`\`\``, color: 0x3498db, timestamp: new Date(), footer: { text: "Network Diagnostics" } @@ -834,6 +837,18 @@ case "anime": await interaction.editReply({ embeds: [traceEmbed] }); }); + + traceroute.on('close', async (code) => { + const finalEmbed = { + title: "Traceroute Complete", + description: `Target: ${target}\nMax Hops: ${maxHops}\n\n\`\`\`\n${output}\`\`\``, + color: 0x00ff00, + timestamp: new Date(), + footer: { text: "Network Diagnostics" } + }; + + await interaction.editReply({ embeds: [finalEmbed] }); + }); } catch (error) { console.error(error); await interaction.editReply({ @@ -841,7 +856,8 @@ case "anime": ephemeral: true }); } - break; case "whois": + break; + case "whois": try { await interaction.deferReply(); const domain = interaction.options.getString("domain");