Skip to content

Commit 3b6208a

Browse files
committed
docs(projects): add content for discord anti-spam bot
1 parent 259702f commit 3b6208a

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Discord Anti-Spam Detection Bot
2+
- **Difficulty:** Advanced (Machine Learning, Cloud Infrastructure, DevOps)
3+
- **Status:** Active (Production Deployment
4+
5+
## The Motivation: "With Utmost Pleasure..."
6+
If you have been on Discord for more than a week, you have seen it. A message pops up in a general channel or your DMs:
7+
8+
> *"With utmost pleasure, I'm giving out my MacBook pro 2025... It is in perfect health... Strictly First come first serve..."*
9+
10+
It’s spam, it’s annoying, and it targets the most vulnerable members of a community. While regex filters catch some of these, scammers evolve. They change fonts, use images, or use social engineering ("I accidentally reported your account!"). We built this bot not just to filter keywords, but to understand **context**.
11+
12+
---
13+
14+
## Part 1: Securing Your Community (What We Learned)
15+
Before we even talk about our bot, we want to share some things we learned during development. Here are our recommendations:
16+
17+
### 1. The "Welcome" Firewall
18+
Don't let new users chat immediately.
19+
* **Verification:** Set your server to "High" (requires a verified phone/email).
20+
* **Rules Screening:** Enable "Membership Screening." Users must explicitly click to accept rules before typing. This breaks many low-effort script bots.
21+
22+
### 2. Native AutoMod is Powerful
23+
Discord has released great tools recently that many admins overlook:
24+
* **Mention Spikes:** You can configure AutoMod to block messages that mention a specific number of unique users (e.g., 5+). This kills "mass ping" attacks instantly.
25+
* **The @everyone Risk:** Restrict the ability to mention `@everyone` and `@here` to Admins only.
26+
27+
### 3. Free vs. Nitro
28+
A common misconception is that you need to pay for security. You don't. While Nitro offers perks like bigger file uploads, the core security suite (AutoMod, Audit Logs, Verification) is entirely free. Our bot is designed to complement these free tools, filling the specific gaps they miss.
29+
30+
---
31+
32+
## Part 2: The Bot Capabilities
33+
When native tools aren't enough, our bot steps in. It's currently processing messages with **97.8% accuracy**.
34+
35+
### 🤖 Hybrid Detection Pipeline
36+
We use a "Swiss Cheese" model of defense. If a message gets past one layer, the next one catches it.
37+
1. **Regex Layer (The Speed):** Instantly catches known scam patterns (like the MacBook copypasta or "steam nitro" links) with zero latency.
38+
2. **ML Layer (The Brains):** If a message passes the regex check, it is analyzed by a **BERT Transformer model** (specifically fine-tuned on spam data). This understands context—it can tell the difference between someone *discussing* a scam and someone *posting* one.
39+
40+
### 📊 Real-Time Analytics Dashboard
41+
Security shouldn't be a black box. We built a comprehensive `!stats` dashboard that provides transparency into the system's performance:
42+
* **Live Session Stats:** Tracks uptime, messages analyzed per hour, and detection rates.
43+
* **System Health:** Monitors CPU and RAM usage (optimized to run on just 2GB RAM).
44+
* **Accuracy Metrics:** Tracks false positives vs. true positives in real-time.
45+
46+
### 🛡️ Smart Moderation & Permission Hierarchy
47+
The bot respects the chain of command.
48+
* **Role-Based Whitelisting:** We implemented a robust permission system. Admins and Moderators are automatically whitelisted from checks to prevent accidental flags during server maintenance.
49+
* **Context-Aware Help:** The `!help` command is dynamic. Regular users see public commands, while Moderators and Admins see advanced diagnostic tools (`!check`, `!dataset_info`) based on their specific role permissions.
50+
51+
### 🚨 False Positive Resolution
52+
No AI is perfect. If the bot makes a mistake, we made it incredibly easy to fix.
53+
* **Reaction Workflow:** A moderator simply reacts with ❌ to the log message.
54+
* **Auto-Correction:** The bot immediately restores the message to the channel, unbans/unmutes the user, and updates its internal dataset to learn from the mistake.
55+
56+
---
57+
58+
## Technical Stack & Infrastructure
59+
* **Core:** Python 3.12, discord.py (Async/Await for concurrency)
60+
* **AI/ML:** PyTorch, Transformers (Hugging Face)
61+
* **Data Engineering:** Thread-safe CSV pipelines for dataset generation.
62+
* **Hosting:** cloud infrastructure.
63+
64+
## Privacy & Open Source
65+
We believe you should own your community's data. While this bot logs data to build a training dataset for future research, these logging features are **optional** and can be disabled for privacy.
66+
67+
*Want to see it in action? Join our Discord and check the `#🚫wall-of-shame` channel!*

0 commit comments

Comments
 (0)