I'm wanting to scan a message/string for an IP address, I've managed to get it to check if the whole thing matches but I cannot get it to check if it contains an IP
Here's what I've tried
let ipRegex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
if(message.content.match(ipRegex)) {
client.sql.query(`SELECT autoDelIPs, modlog FROM guildconfig WHERE guildID = ?`, [message.guild.id], async function (error, results, fields) {
if(results[0].autoDelIPs === 1) {
if(results[0].modlog !== "0" || results[0].modlog !== "000000000000000000") {
let logemb = new Discord.MessageEmbed().setTitle("IP Detected").addField("User", message.author.tag, true).addField("Sent", message.content, true).addField("In", "<#" + message.channel.id + ">", true).setColor("RED").addField("Action Taken", "Message deleted", true)
message.guild.channels.cache.get(results[0].modlog).send(logemb)
message.delete()
message.channel.send("An IP was detected to be sent by " + message.author.tag + " and was deleted, a log has been sent into the modlog channel!")
} else {
message.delete()
message.channel.send("An IP was detected to be sent by " + message.author.tag + " and was deleted, no log has been made as a modlog was not set!")
}
}
})
}
Using this code here are some output examples:
Message: Look at my ip 1.1.1.1 lol
Output: Nothing happens
Message: 8.8.8.8
Output: An IP was detected to be sent
I have tried looking for myself for an answer but could not find any, I know it might be a stupid question but I can't find any answers to my problem