This commit is contained in:
Xargana 2025-03-30 09:25:49 +03:00
parent 75a1f69655
commit 89e50fab13

View file

@ -821,30 +821,39 @@ case "anime":
const maxHops = interaction.options.getInteger("hops") || 30; const maxHops = interaction.options.getInteger("hops") || 30;
const { spawn } = require('child_process'); const { spawn } = require('child_process');
const traceroute = spawn('traceroute', ['-m', maxHops, target]); const traceroute = spawn('traceroute', ['-n', '-m', maxHops, target]); // Added -n flag for numeric output
let output = ''; let output = '';
traceroute.stdout.on('data', async (data) => { traceroute.stdout.on('data', async (data) => {
output += data.toString(); // Process each line to make it more compact
const newData = data.toString()
.split('\n')
.map(line => {
// Remove extra spaces and asterisks
return line.replace(/\s+/g, ' ').replace(/\* \* \*/g, '*');
})
.join('\n');
output += newData;
const traceEmbed = { const traceEmbed = {
title: "Traceroute Results (Live)", title: `📍 Trace to ${target}`,
description: `Target: ${target}\nMax Hops: ${maxHops}\n\n\`\`\`\n${output}\`\`\``, description: `\`\`\`\n${output}\`\`\``,
color: 0x3498db, color: 0x3498db,
timestamp: new Date(), timestamp: new Date(),
footer: { text: "Network Diagnostics" } footer: { text: "🔍 Tracing..." }
}; };
await interaction.editReply({ embeds: [traceEmbed] }); await interaction.editReply({ embeds: [traceEmbed] });
}); });
traceroute.on('close', async (code) => { traceroute.on('close', async () => {
const finalEmbed = { const finalEmbed = {
title: "Traceroute Complete", title: `📍 Trace to ${target} - Complete`,
description: `Target: ${target}\nMax Hops: ${maxHops}\n\n\`\`\`\n${output}\`\`\``, description: `\`\`\`\n${output}\`\`\``,
color: 0x00ff00, color: 0x00ff00,
timestamp: new Date(), timestamp: new Date(),
footer: { text: "Network Diagnostics" } footer: { text: "✅ Trace complete" }
}; };
await interaction.editReply({ embeds: [finalEmbed] }); await interaction.editReply({ embeds: [finalEmbed] });