PLEASE DO NOT click on any links I’ve provided here! It’s a real scam link, used for the example!
Hello,
Me, and a friend of mine has worked on an anti-phishing bot, although Discord themself are detecting the links now.
We’ve successfully made the bot detect and take action if a link is detected with the API we use, so for example, I’ll use discordnitro.com — which is a scam link.
The current code + the working one below:
const regex = /https?://[^s$.?#].[^s]*.[^s]{2,}/g;
client.on("messageCreate", (message) => {
if (message.content.match(regex)) {
let msg = message.content;
let result = msg.replace(/(^w+:|^)///, "");
fetch(`url/${result}`)
.then(res => res.json())
.then(json => {
if (json == true) {
message.delete();
const embed = new EmbedBuilder()
.setColor("#ed553e")
.setAuthor({ name: "Phishing Link Detected", iconURL: message.author.avatarURL() })
.setThumbnail(message.author.avatarURL())
.setDescription("**User: **" + "<@" + message.author.id + ">" + "n" + "**ID: **" + "`" + message.author.id + "`" + "n" + "**Domain: **" + "||" + result + "||")
.setTimestamp()
message.channel.send({ embeds: });
}
});
}
});
Also, we currently do not take mod action, but that’ll be added soon.
So, the bot successfully detects when an user sends the following link (example): https://discordnitro.com
, but does not detect the link if it’s as https://discordnitro.com/freenitro
.
How can I make the bot detect the link if anything is added after the /?
Thanks.