The Spam Filter Bot is designed to counteract spam and scam messages in Discord servers. It intelligently evaluates messages based on multiple criteria, automatically removes spammy content, and notifies admins.
- Account Age Check
Flags accounts less than a configurable number of days old (default: 5 days). - Link Detection
Identifies messages containing suspicious links or Discord invite links. - Keyword Detection
Flags messages containing specific keywords (e.g., "fullstack", "blockchain", etc.). - Mentions Detection
Detects messages containing excessive mentions of@everyone
or@here
. - AI-Based Scam Analysis
Uses AI to analyze whether messages are likely scams, with specific emphasis on developers introducing themselves. - Timeout System
Automatically applies a timeout to users who send flagged messages. - Admin Logging
Logs flagged messages in a designated admin channel for review.
The bot evaluates messages against five checks. If two or more checks are flagged, the message is considered spam:
- Account Age
Checks the age of the message sender's account. - Links
Flags any messages with suspicious or invite links. - Keywords
Scans for predefined suspicious keywords. - Mentions
Identifies messages with excessive use of@everyone
or@here
. - AI Content Analysis
Sends the message to an AI model for scam detection.
When flagged, the bot will:
- Delete the message.
- Log the incident in the admin log channel.
- Timeout the user for a configurable period (default: 10 seconds).
- Python 3.8+ installed.
- A Discord bot token.
- OpenRouter API key for AI analysis.
- Required permissions for the bot:
Manage Messages
Timeout Members
View Audit Log
- Clone the repository:
git clone https://github.com/saked004/spam-filter-bot.git cd spam-filter-bot
- Install dependencies
pip install -r requirements.txt
- Create a
.env
file in the project root and add your keys:DISCORD_BOT_TOKEN= OPEN_ROUTER_API_KEY= ADMIN_LOG_CHANNEL_ID= AI_BASE_URL = TIME_OUT =
- Configure settings (optional):
Modify settings in the
utils/config.py
file, such as account age thresholds, keywords, and timeout duration.
- Start the bot with:
python bot.py
spam-filter-bot/
│
├── bot.py
├── checks/
│ ├── account_age_check.py
│ ├── link_check.py
│ ├── keyword_check.py
│ ├── mention_check.py
│ └── ai_check.py
│
├── utils/
│ ├── config.py
│ └── logger.py
│
├── requirements.txt
├── .env
└── README.md
Modify Keywords
- Edit KEYWORD_LIST in
checks/keyword_check.py
to add/remove keywords.
Change Account Age Threshold
- Update the
ACCOUNT_AGE_THRESHOLD
inchecks/account_age_check.py
.
Adjust Timeout Duration
- Modify the
TIMEOUT_DURATION
inbot.py
(default: 10 seconds).
This project is licensed under the MIT License.