Add NSFW-only filtering mode for content moderation
Some checks failed
NSFW-Only Filtering Tests / NSFW-Only Filtering Feature Tests (push) Has been cancelled

- Add nsfw_only_filtering field to GuildSettings model
- Create database migration for new field (20260124_add_nsfw_only_filtering)
- Update AI moderation logic to respect NSFW-only mode
- Add Discord command !ai nsfwonly <true/false> for toggling mode
- Implement filtering logic in image analysis for both attachments and embeds
- Add comprehensive test suite for new functionality
- Update documentation with usage examples and feature description
- Create dedicated CI workflow for testing NSFW-only filtering feature

When enabled, only sexual/nude content is filtered while allowing:
- Violence and gore
- Harassment and bullying
- Hate speech
- Self-harm content
- Other content categories

This mode is useful for gaming communities and mature discussion
servers that have specific content policies allowing violence
but prohibiting sexual material.
This commit is contained in:
2026-01-24 23:51:10 +01:00
parent 824dd681f7
commit 1250b5573c
6 changed files with 748 additions and 14 deletions

View File

@@ -19,6 +19,7 @@ GuardDen is a comprehensive Discord moderation bot designed to protect your comm
### AI Moderation
- **Text Analysis** - AI-powered content moderation using Claude or GPT
- **NSFW Image Detection** - Automatic flagging of inappropriate images
- **NSFW-Only Filtering** - Option to only filter sexual content, allowing violence/harassment
- **Phishing Analysis** - AI-enhanced detection of scam URLs
- **Configurable Sensitivity** - Adjust strictness per server (0-100)
@@ -177,7 +178,7 @@ Each server can configure:
- Automod toggles (spam, links, banned words)
- Automod thresholds and scam allowlist
- Strike action thresholds
- AI moderation settings (enabled, sensitivity, confidence threshold, log-only, NSFW detection)
- AI moderation settings (enabled, sensitivity, confidence threshold, log-only, NSFW detection, NSFW-only mode)
- Verification settings (type, enabled)
## Commands
@@ -245,6 +246,7 @@ Managed wordlists are synced weekly by default. You can override sources with
| `!ai threshold <0.0-1.0>` | Set AI confidence threshold |
| `!ai logonly <true/false>` | Toggle AI log-only mode |
| `!ai nsfw <true/false>` | Toggle NSFW image detection |
| `!ai nsfwonly <true/false>` | Toggle NSFW-only filtering mode |
| `!ai analyze <text>` | Test AI analysis on text |
### Diagnostics (Admin only)
@@ -386,6 +388,23 @@ The AI analyzes content for:
3. Actions are taken based on guild sensitivity settings
4. All AI actions are logged to the mod log channel
### NSFW-Only Filtering Mode
For communities that only want to filter sexual content while allowing other content types:
```
!ai nsfwonly true
```
**When enabled:**
- ✅ **Blocked:** Sexual content, nude images, explicit material
- ❌ **Allowed:** Violence, harassment, hate speech, self-harm content
**When disabled (normal mode):**
- ✅ **Blocked:** All inappropriate content categories
This mode is useful for gaming communities, mature discussion servers, or communities with specific content policies that allow violence but prohibit sexual material.
## Development
### Running Tests