Fixes
This commit is contained in:
parent
b15f7097f8
commit
5f750b0666
@ -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)}...`);
|
||||
|
@ -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}
|
||||
|
@ -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(() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user