A powerful Discord bot that automatically moderates messages using the Groq API for AI-based content analysis. The bot detects inappropriate content, including hate speech, explicit content, harassment, and more, without requiring any manual commands.
- Automatic Message Moderation: Analyzes all messages in real-time using Groq's AI models
- Configurable Sensitivity: Adjust how strict the moderation should be
- Graduated Warning System: Tracks user warnings with automatic escalating actions
- Automatic Actions: Timeouts, kicks, and bans based on violation history
- Detailed Logging: Records all moderation actions in private mod-logs channels
- Auto-create Moderation Logs: Creates a private mod-logs channel automatically if one doesn't exist
- Dual Notifications: Sends moderation notices to both user DMs and staff mod-logs
- Status Rotation: Displays dynamic bot status messages that rotate periodically
- Persistent Storage: Local file storage with automatic backups
- Slash Commands: Moderator commands for checking and managing warnings
- Customizable Settings: Extensive configuration options
- Node.js 16.9.0 or higher
- A Discord bot token
- A Groq API key
- Clone the repository:
git clone https://github.com/friday2su/ai-moderation.git
cd ai-moderation
- Install dependencies:
npm install
-
Configure your environment variables:
- Rename
.env.exampleto.env - Add your Discord bot token and Groq API key:
DISCORD_TOKEN=your_discord_bot_token GROQ_API_KEY=your_groq_api_key - Rename
-
Start the bot:
npm start
- Go to the Discord Developer Portal
- Click "New Application" and give it a name
- Go to the "Bot" tab and click "Add Bot"
- Under "Privileged Gateway Intents", enable:
- MESSAGE CONTENT INTENT
- SERVER MEMBERS INTENT
- Copy your bot token and add it to the
.envfile - Go to OAuth2 > URL Generator, select:
- Scopes: bot, applications.commands
- Bot Permissions:
- Read Messages/View Channels
- Send Messages
- Manage Messages
- Kick Members
- Ban Members
- Moderate Members
- Read Message History
- Manage Channels (needed to create mod-log channels)
- Use the generated URL to invite the bot to your server
- Sign up for an account at Groq
- Generate an API key from your dashboard
- Add the API key to your
.envfile
The bot is highly configurable through the config.js file:
strictMode: Set totruefor stricter moderationignoredChannels: Array of channel IDs to skip moderationignoredRoles: Array of role IDs that are exempt from moderationsensitivity: Value between 0-1 controlling moderation sensitivity
modLogChannels: Channel names to look for when logging moderation actionscreateLogChannel: When set totrue, the bot will automatically create a private mod-logs channel if none existslogAllDecisions: Whether to log all moderation decisionsincludeMessageContent: Whether to include the moderated message content in logscensorMessageContent: Whether to censor potentially offensive words in log messagesmaxContentLength: Maximum length of message content to show in logs
statusRotationInterval: How often to rotate the bot's status messages (in milliseconds)customStatuses: Array of custom status objects to display, with format:{ type: "WATCHING", text: "for violations" }
- Valid types:
PLAYING,STREAMING,LISTENING,WATCHING,CUSTOM,COMPETING - Dynamic placeholders:
{serverCount}- Number of servers the bot is in{sensitivity}- Current moderation sensitivity level{strictMode}- Whether strict mode is enabled (ON/OFF){recentActivity}- Shows recent moderation activity with formats:- "all clear" - when no flags in the last hour
- "X flags (active)" - when flagged messages in the last 10 minutes
- "X flags this hour" - summary of flags in the current hour
- Valid types:
autoSaveInterval: How often to save data to disk (in minutes)createBackups: Whether to create backups before overwriting data filesmaxBackups: Maximum number of backup files to keepsaveOnShutdown: Whether to save data when the bot shuts down
expiresAfterDays: Days until warnings expire (set to 0 for no expiration)actionThresholds: Warning counts that trigger different moderation actions
See config.js for all available configuration options.
The bot provides several slash commands for moderators:
/warnings <user>: View the warning history for a specific user/clearwarnings <user>: Clear all warnings for a specific user/modstats: View moderation statistics for the server/forcesave: Force save all warning data to disk (requires Admin permissions)
Warning data is stored locally in the data directory:
warnings.json: Contains all user warnings and action historybackups/: Contains automatic backups created before overwriting data
The storage system includes:
- Automatic saving at configurable intervals
- File backups with rotation
- Graceful shutdown to prevent data loss
MIT
Made By Friday | Powered By Cortex Realm
Support Server: Join Here
Copyright (c) 2025 Friday | Cortex Realm