Sven is a Discord bot that utilizes OpenAI's Moderation API for text moderation and HuggingFaces' transformer model for image moderation. This bot helps maintain a safe and respectful environment in your Discord server. This bot is COMPLETELY FREE to use as OpenAI's Moderation API is free, and so is HuggingFace! Your OpenAI API key is only needed to prove to OpenAI that you are an API user. Rest assured however, you will not be charged!
![Screenshot 2023-05-15 at 9 14 12 PM](https://private-user-images.githubusercontent.com/107640947/238531265-95324ac4-5b76-4124-9679-e8f8dabb299d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg1NTcwMzEsIm5iZiI6MTcxODU1NjczMSwicGF0aCI6Ii8xMDc2NDA5NDcvMjM4NTMxMjY1LTk1MzI0YWM0LTViNzYtNDEyNC05Njc5LWU4ZjhkYWJiMjk5ZC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjE2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYxNlQxNjUyMTFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0xOWQ2YzIzZGNmNDhlNmJmNTYxMjA2ZDUyNzMwZDMzMDc2ZDBhMjNlYThhMzM5YjcwOTY2NTM5MTY5YzNmZjc1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.K0BDrfxwmBY6eFqwCMZUd7eDvmmtmlCq6-dJ2yT3m3g)
π Add an Invite-Ready, Hosted Sven Here: Invite Sven
- Text moderation using OpenAI's Moderation API
- Image moderation using HuggingFaces' transformer model
- Warns and mutes users for inappropriate messages
- Configurable warning limit and mute duration
Follow these steps to set up your own instance of AI-Discord-Mod:
Ensure you have the following installed:
- Python 3.6 or later
- pip (Python package installer)
Install the necessary Python packages with the following commands:
pip install -r requirements.txt
pip install transformers datasets
pip install torch # or pip install tensorflow depending on your preference
- Go to the Discord Developer Portal.
- Click on "New Application". Give it a name and click on "Create".
- Go to the "Bot" tab and click on "Add Bot". You will see a message saying "A wild bot has appeared!", click "Yes, do it!".
- Under the "Token" section, click on "Copy". This will be your DISCORD_BOT_TOKEN. Remember to keep this secret!
- Go to the "OAuth2" tab, under "Scopes" tick "bot", then under "Bot Permissions" tick "Administrator".
- You will see a generated URL, use this URL to invite your bot to your Discord server.
- Clone this repository to your local machine:
git clone https://github.com/gravelBridge/AI-Discord-Mod.git
- Navigate to the project directory:
cd AI-Discord-Mod
- Copy the .env.template file and rename it to .env:
cp .env.template .env
- Open the .env file in a text editor and replace the placeholders with your
OPENAI_API_KEY
andDISCORD_BOT_TOKEN
. Set theUSE_TRIGGERING_WORDS
andTRIGGERING_WORDS
values as per your preference. - Your .env file should look like this:
# OPENAI_API_KEY: Your OpenAI API Key, must be connected to an account with a payment method. OPENAI_API_KEY=your_openai_api_key #DISCORD_BOT_TOKEN: Your Discord Bot Token that's in your Discord Server. DISCORD_BOT_TOKEN=your_discord_bot_token # USE_TRIGGERING_WORDS: If the bot should only send requests for moderation if the message contains a triggering word that is defined below. USE_TRIGGERING_WORDS=True # TRIGGERING_WORDS: A txt file directory to a list of triggering words, comma separated, that have to sent in order for message to be checked via AI. TRIGGERING_WORDS=The text file directory
- Save and close the
.env
file.
To run the bot, navigate to the project directory and run:
python ai-discord-moderator/discord_bot.py
For help, run the /help command in your discord server!
The bot should now be active in your Discord server and automatically moderate text and images based on the rules defined in the ai_discord_functions.py and discord_bot.py scripts.
This bot uses AI models which, while powerful, might not always make perfect decisions. It is recommended to have human moderators oversee the bot's actions for best results.
This project is licensed under the GPL-3.0 License. See the LICENSE file for details.