Detetective Discord
๐ก
Inspiration
Have you ever recieved a message like this?
If you have been on Discord for a while, I am sure you have been warned to stay away from these links.
But what about the newbies that are just starting out?
One of such incidents happend this thursday on my server. A bunch of people fell victim to such phishing links.
There was no such bots available in the market to solve this problem so I decided to make it on my own.
๐ป
What it does
Detective Discord is a bot that detects phishing links in Discord messages, deletes them, warns the user who sent them and increase thier warning count by 1. Once the warning count reaches 3, the user is banned from the server.
In case of a ban, the user is also informed by the bot for the same.
This bot can also perform a few other actions like:
- $news - Get latest news from BBC
- $weather - Get weather in a city
- $joke - Get a random joke
- $wiki - Get a summary of a search key from Wikipedia
- $help - Get this message
- $reset_warn - Reset warnings for a user (admin/moderator only)
โ๏ธ
How I built it
The rules to detect phishing links are simple:
- Check if the message contains a link.
- Check if the link is not exactly the same as the real discord links like discord.gg or discord.me.
- Calculate the Levenstien Distance between the link and the real discord links.
- If the distance is less than 4, or the message contains words like discord or nitro, the link is considered to be phishing link.
For fetching the News, the bot uses the BBC API.
For fetching the weather, the bot uses the OpenWeatherMap API.
For fetching the jokes, the bot uses the pyjokes python library.
For fetching the Wikipedia summary, the bot uses the Wikipedia python library.
โ๏ธ
Tech Stack
๐ง
Challenges we ran into
At first, I thought it would be a really simple task but as I started to build it, I realized it wasn't that easy after all.
Firstly I had to make the rules to identify phishing links. But I also had to make sure that the bot would not delete the links that are not phishing links.
After hovering over various methods, I settled on using the Levenstien Distance algorithm.
After that, when testing the bot I realized that the bot would also delete the links that were not phishing links but other discord links.
So I had to tweak the rules and make them inclusive to the other links.
Finally, I had a hard time deleting the user from the database who sent the phishing links. There was a bug that I wasn't able to detect and it took me 1 whole hour to fix it.
๐
Accomplishments that we're proud of
I am proud of the fact that I was able to build this bot in a day and that now my Server will no longer suffer from these phishing scams.
๐
What we learned
This is the first time I have build a discord bot. I learnd how to use the discord.py library and how to use the discord.py API.
๐
What's next for Detetective Discord
Setting a workflow to save the phishing links in the database and at the stroke of the midnight, report them through the appropriate channels.