From 5f750b066602512e08ebaf92c23da972f5016f3a Mon Sep 17 00:00:00 2001
From: Wizzard <rich@bandaholics.cash>
Date: Fri, 11 Apr 2025 06:48:39 -0400
Subject: [PATCH] Fixes

---
 commands/autodelete.js | 12 ++++++++++++
 commands/ip.js         | 33 +++++++++++++++++++++++++++++----
 utils/messageUtils.js  |  2 ++
 3 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/commands/autodelete.js b/commands/autodelete.js
index 2e42f86..502d99f 100644
--- a/commands/autodelete.js
+++ b/commands/autodelete.js
@@ -173,6 +173,18 @@ const handleNewMessage = (message) => {
         ignoredMessages.add(message.id);
         return;
     }
+    
+    if (message.content.includes('```') && message.content.length > 100) {
+        console.log(`[AUTODELETE] Skipping command response message: ${message.id}`);
+        ignoredMessages.add(message.id);
+        return;
+    }
+    
+    if (message.scheduledForDeletion) {
+        console.log(`[AUTODELETE] Skipping message already scheduled for deletion: ${message.id}`);
+        ignoredMessages.add(message.id);
+        return;
+    }
 
     console.log(`[AUTODELETE] New message tracked: ${message.id}`);
     console.log(`[AUTODELETE] Content preview: ${message.content.slice(0, 30)}...`);
diff --git a/commands/ip.js b/commands/ip.js
index e526dbf..59b0fb7 100644
--- a/commands/ip.js
+++ b/commands/ip.js
@@ -24,14 +24,30 @@ function isVpnIp(ip) {
     return false;
 }
 
+function isValidIp(ip) {
+    const ipRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
+    return ipRegex.test(ip);
+}
+
 module.exports = {
     name: 'ip',
-    description: 'Fetches IP info and checks if the IP is a VPN.',
+    description: 'Fetches IP info and checks if the IP is a VPN. Usage: .ip [ip_address]',
     async execute(message, args, deleteTimeout) {
         const { default: fetch } = await import('node-fetch');
         try {
-            const ipRes = await fetch('http://ip-api.com/json/');
-            const data = await ipRes.json();
+            let targetIp;
+            
+            if (args.length > 0) {
+                targetIp = args[0];
+                if (!isValidIp(targetIp)) {
+                    await sendCommandResponse(message, "Invalid IP address format. Please use format: x.x.x.x", deleteTimeout, true);
+                    return;
+                }
+            } else {
+                const ipRes = await fetch('http://ip-api.com/json/');
+                const data = await ipRes.json();
+                targetIp = data.query;
+            }
 
             if (!vpnRangesCache) {
                 const vpnRes = await fetch('https://raw.githubusercontent.com/X4BNet/lists_vpn/main/ipv4.txt');
@@ -39,6 +55,14 @@ module.exports = {
                 vpnRangesCache = vpnText.split('\n').map(line => line.trim()).filter(line => line);
             }
 
+            const ipRes = await fetch(`http://ip-api.com/json/${targetIp}`);
+            const data = await ipRes.json();
+
+            if (data.status === 'fail') {
+                await sendCommandResponse(message, `Error: ${data.message}`, deleteTimeout, true);
+                return;
+            }
+
             const ip = data.query || "Unknown";
             const vpnCheck = isVpnIp(ip);
 
@@ -53,7 +77,8 @@ module.exports = {
             const as = data.as || "Unknown";
 
             const output =
-                `Hostname: ${hostname}
+                `IP: ${ip}
+Hostname: ${hostname}
 City: ${city}
 Region: ${region}
 Country: ${country}
diff --git a/utils/messageUtils.js b/utils/messageUtils.js
index d622041..6894a4b 100644
--- a/utils/messageUtils.js
+++ b/utils/messageUtils.js
@@ -12,6 +12,8 @@ const sendTempMessage = async (channel, content, baseDeleteDelay = 5000) => {
         const deleteDelay = getHumanizedDeleteDelay(baseDeleteDelay);
         const sentMessage = await channel.send(content);
         
+        sentMessage.scheduledForDeletion = true;
+        
         console.log(`[MESSAGE] Sending temp message in ${channel.id}, will delete in ${deleteDelay}ms`);
         
         setTimeout(() => {