A C# Discord bot that automatically scans messages for links and detects potential scam or phishing URLs by checking them against a SQLite database. Now includes slash commands to control defending mode, secure configuration for token management, and automatic database updates from GitHub!
- π Automatic Link Scanning: Monitors all messages for URLs
β οΈ Scam Detection: Checks URLs against a SQLite database of known scam domains- π¨ Real-time Alerts: Sends warning messages when scam links are detected
- πΎ SQLite Database: High-performance, reliable database storage using Entity Framework Core
- π‘οΈ Safe Operation: Bot ignores its own messages and other bots
- π Guild-Only Commands: NEW! All commands restricted to Discord servers for security
- β‘ Slash Commands: Control defending mode with
/activate,/deactivate,/status,/update,/check,/report,/whitelist,/stats,/export,/config,/scan,/history, and/recent - π Interactive Reporting: NEW! Report malicious domains using Discord's modal forms for better user experience
- ποΈ Toggle Protection: Enable or disable link scanning on demand
- π Triple Protection: Local database + Phish.Sinking.Yachts + Anti-Fish API detection
- π§ Auto-Learning: NEW! Automatically adds API-detected domains to SQLite database
- πΎ Persistent Settings: NEW! Guild defending mode settings survive bot restarts
- π¦ Database Migration: NEW! Automatically migrates from legacy text files to SQLite
- β Whitelist Management: NEW! Add trusted domains to prevent false positives
- π Advanced Statistics: NEW! Comprehensive protection statistics and analysis
- π Manual Scanning: NEW! Scan historical messages for threats
- π Activity Tracking: NEW! View detection history and recent activity
- βοΈ Server Configuration: NEW! Customize bot behavior per server
- π Data Export: NEW! Export data for analysis and reporting
The bot uses a sophisticated three-tier detection system for comprehensive threat analysis:
- Downloads from Discord-AntiScam GitHub repository
- Updates automatically on startup using Entity Framework Core
- Community-maintained list of known scam domains stored in SQLite
- β‘ Instant lookup with in-memory caching for maximum performance
- π Import tracking with detailed logs and statistics
- Real-time phishing detection via phish.sinking.yachts
- Community-driven phishing domain database
- π Community intelligence for emerging threats
- Advanced threat analysis via anti-fish.bitflow.dev
- AI-powered scam detection engine
- π Real-time analysis for unknown threats
Domain Found β Check Local Database β Check Phish.Sinking.Yachts β Check Anti-Fish API β Report if Flagged β Auto-Add New Domains
- Manual
/check: Full three-tier analysis with detailed reporting + auto-learning - Automatic Scanning: Optimized two-tier (Local + Anti-Fish) for performance + auto-learning
- Emergency Scanning: Adds Sinking Yachts if Anti-Fish is unavailable + auto-learning
- Auto-Learning: NEW! All API detections automatically added to local database
The bot now features intelligent auto-learning with SQLite database storage that continuously improves protection:
- API Detection: When APIs detect a scam domain not in SQLite database
- Automatic Addition: Domain is immediately added to
nophishing.dbSQLite database - Instant Protection: New domain becomes available for future checks via in-memory cache
- Source Attribution: Records which API detected the domain with timestamps
- Thread-Safe: Multiple detections handled safely using Entity Framework Core
New Domain Detected by API β Check SQLite DB β If Not Found β Add to Database β Update In-Memory Cache β Log Import Details
β
Continuous Improvement: Database grows with each new threat discovered
β
Zero Maintenance: No manual intervention required for new domains
β
Faster Future Detection: API-detected domains become local for instant lookup
β
Community Contribution: Local discoveries benefit from external intelligence
β
Persistent Learning: Added domains survive bot restarts in SQLite
β
Import Tracking: Detailed logs of all database imports and updates
β
High Performance: Entity Framework Core with in-memory caching
π New scam domain detected by Anti-Fish API: malicious-new-site.com
π Added new scam domain to database: malicious-new-site.com (detected by Anti-Fish API)
ποΈ SQLite database now contains 1,268 domains
π Import completed: 1 new domains, 0 skipped
π Migrating legacy scam_links.txt to database...
π Imported 1,267 domains from legacy file
β
Legacy migration completed successfully
ποΈ Legacy file backed up as scam_links.txt.bak
The bot now features persistent storage of defending mode settings per Discord server (guild):
- Guild-Specific Settings: Each Discord server has its own defending mode state
- Automatic Storage: Settings are saved to
bot_settings.jsonwhen changed - Restart Survival: Defending mode settings survive bot restarts
- Thread-Safe Storage: Multiple guild operations handled safely
{
"Guilds": {
"123456789012345678": {
"GuildId": 123456789012345678,
"DefendingModeActive": true,
"LastActivated": "2025-01-07T10:30:00.000Z",
"ActivatedBy": "AdminUser"
}
},
"LastUpdated": "2025-01-07T10:30:00.000Z"
}β
No Manual Reactivation: Bot remembers which servers had protection enabled
β
Per-Server Control: Each Discord server maintains independent settings
β
Audit Trail: Track who activated/deactivated defending mode and when
β
Automatic Backup: Settings are saved immediately when changed
β
Zero Configuration: Settings file is created automatically
bot_settings.json- Guild defending mode settings (auto-generated)nophishing.db- SQLite database with scam domains (auto-generated)scam_links.txt- Legacy file (migrated to database on first run)
The bot features an interactive modal form system for reporting potentially malicious domains:
- Easy Access: Use the
/reportslash command - Modal Form: Discord opens an interactive form with three fields:
- Domain to Report (required): The suspicious domain or URL
- Reason for Reporting (optional): Why you think it's malicious
- Additional Details (optional): Extra context or information
- Smart Processing: Bot automatically normalizes domains and validates input
- Developer Notification: Reports are sent to the configured developer via DM
- Database Storage: All reports are saved to the database for review
β
User-Friendly Interface: Professional modal form instead of command parameters
β
Flexible Input: Accept full URLs or just domain names
β
Rich Context: Collect detailed reasons and additional information
β
Automatic Validation: Ensure required fields are filled
β
Smart Normalization: Clean up URLs to extract domains properly
β
Dual Storage: Save to database and attempt developer notification
β
Detailed Responses: Professional embed responses with report IDs
User: /report
Bot: [Opens modal form]
User: [Fills form with domain, reason, details]
Bot: β
Report Submitted Successfully
Domain: suspicious-site.com
Report ID: A1B2C3D4E5F6
Status: π§ Sent to developer
| Command | Description | Usage |
|---|---|---|
/activate |
Enable defending mode - bot will scan messages for scam links | /activate |
/deactivate |
Disable defending mode - bot stops scanning messages | /deactivate |
/status |
Check current defending mode status, database info, persistence, auto-learning, and SQLite statistics | /status |
| Command | Description | Usage |
|---|---|---|
/update |
Manually trigger an update of the scam links database | /update |
/check |
Check a specific domain against the scam database using three-tier validation | /check domain:example.com |
/scan |
Manually scan recent messages in a channel for scam links | /scan channel:#general messages:50 |
| Command | Description | Usage |
|---|---|---|
/whitelist add |
Add a trusted domain to the server whitelist | /whitelist action:add domain:example.com reason:"Company website" |
/whitelist remove |
Remove a domain from the server whitelist | /whitelist action:remove domain:example.com |
/whitelist list |
Show all whitelisted domains for this server | /whitelist action:list |
| Command | Description | Usage |
|---|---|---|
/report |
Report a potentially malicious domain to the developers using an interactive form | /report |
/stats |
Show comprehensive protection statistics for this server | /stats |
/history |
View domain detection history (optionally filtered by domain) | /history domain:example.com days:7 |
/recent |
View recent bot activity (detections, reports, or updates) | /recent type:detections count:10 |
| Command | Description | Usage |
|---|---|---|
/config |
Manage bot configuration settings for this server | /config setting:auto_delete value:true |
/export |
Export data for analysis (domains, reports, or detections) | /export type:detections days:30 |
The /config command allows you to customize bot behavior:
| Setting | Description | Values |
|---|---|---|
auto_delete |
Automatically delete messages containing scam links | true/false |
send_warnings |
Send warning messages when scams are detected | true/false |
log_detections |
Log all detections to the database | true/false |
log_channel |
Channel to send detection logs to | Channel ID or mention |
manual_review |
Require manual review before taking action | true/false |
scam_threshold |
Number of sources needed to confirm a scam | 1, 2, or 3 |
show |
Display current configuration settings | (no value needed) |
The /export command supports different data types:
| Type | Description | Fields Included |
|---|---|---|
domains |
Export scam domains database | Domain, Source, Date Added, Notes |
reports |
Export user-submitted reports | Domain, Reporter, Reason, Date, Status |
detections |
Export scam detections in this server | Domain, User, Channel, Sources, Date, Actions |
- .NET 9.0 or higher
- Discord account and server (where you have permissions to add bots)
- Basic knowledge of running .NET applications
-
Clone the Repository:
git clone https://github.com/daglaroglou/NoPhishing.git cd NoPhishing -
Install Dependencies:
dotnet restore
-
Configure the Bot:
-
Make use of Environment User Secret variables.
Configuration Options:
DiscordBotToken: Your Discord bot token (required)DeveloperUserId: Your Discord user ID for receiving domain reports (optional)
Security Note: For production, use user secrets or environment variables instead of appsettings.json:
dotnet user-secrets set "DiscordBotToken" "YOUR_BOT_TOKEN_HERE" dotnet user-secrets set "DeveloperUserId" "YOUR_DISCORD_USER_ID_HERE"
-
Build the Bot:
dotnet build
-
Run the Bot:
dotnet run
-
Create a Discord Application:
- Go to https://discord.com/developers/applications
- Click "New Application" and give it a name
- Go to the "Bot" section and create a bot
- Copy the bot token for configuration
-
Required Bot Permissions:
- Read Messages/View Channels
- Send Messages
- Use Slash Commands
- Manage Messages (to delete scam messages)
- Read Message History
- Add Reactions
- Embed Links
-
Invite the Bot:
- Go to OAuth2 β URL Generator
- Select "bot" and "applications.commands" scopes
- Select the required permissions above
- Use the generated URL to invite the bot to your server
To update the bot to the latest version:
-
Pull the Latest Changes:
git pull origin main
-
Rebuild the Application:
dotnet build
-
Restart the Bot:
dotnet run
The bot automatically manages its SQLite database:
- First Run: Creates
nophishing.dband migrates any existingscam_links.txtfile - Automatic Updates: Downloads and imports new domains from GitHub on startup
- Auto-Learning: Adds API-detected domains automatically during operation
- Performance: Uses in-memory caching for fast domain lookups
appsettings.json- Bot configuration (Discord token)bot_settings.json- Persistent guild settings (auto-generated)nophishing.db- SQLite database (auto-generated)scam_links.txt- Legacy file (migrated on first run)
- Invite the bot to your server using the OAuth2 URL generated in the Discord Developer Portal
- Ensure the bot has the necessary permissions to read messages, send messages, and manage messages
- Important: All commands must be used in Discord servers (guilds) - commands in DMs will be rejected
- Use the slash commands to control the bot and check links
- Monitor the bot's activity for real-time scam link detection
- If the bot fails to start, check the console output for error messages
- Common issues include invalid token, missing permissions, or network connectivity problems
- Ensure your configuration is correctly set up (user secrets, environment variables, or appsettings.json)
- For dependency issues, ensure .NET 9.0 or higher is installed
- Commands not working: Ensure you're using commands in a Discord server, not in DMs
- "Guild Required" error: The bot's commands only work in servers where it's been invited
Contributions are welcome! To contribute to the project:
- Fork the repository
- Create a new branch for your feature or bug fix
- Make your changes and commit them
- Push your branch to your forked repository
- Create a pull request describing your changes
Please ensure your code follows the existing C# style and conventions used in the project.
This project is open source. Please check the repository for license details.
If you need help with the bot:
- Check the troubleshooting section above
- Review the console output for error messages
- Ensure all configuration is properly set up
- Verify the bot has the required Discord permissions