A Discord bot that monitors voice chat for inappropriate language using AssemblyAI's transcription service. The bot joins the most populated voice channel, records audio, transcribes it, and detects swear words from a predefined list. It sends warnings to users and logs incidents in a specified channel.
- Automatic Voice Channel Join: Joins the most populated voice channel in a server.
- Audio Recording: Records audio when a user speaks.
- Speech-to-Text Transcription: Transcribes audio using AssemblyAI's API.
- Swear Word Detection: Detects swear words from a predefined list.
- Moderation Alerts: Sends warnings to users and logs incidents in a specified channel.
- Configurable: Easily configure swear words, reconnect timeout, and more via environment variables.
Before running the bot, ensure you have the following:
- Node.js: Version 18 or higher.
- Discord Bot Token: Create a bot on the Discord Developer Portal.
- AssemblyAI API Key: # at AssemblyAI to get your API key.
- Git: To clone the repository.
Clone the repository to your local machine:
git clone https://github.com/justblaxe/vcm.git
cd vcm
Install the required dependencies using npm:
npm install
Create a .env
file in the root directory and add the following variables:
# Discord Bot Token
DISCORD_BOT_TOKEN=your-discord-bot-token
# AssemblyAI API Key
ASSEMBLYAI_API_KEY=your-assemblyai-api-key
# Swear Words (comma-separated)
SWEAR_WORDS=badword,test,bad
# Reconnect Timeout (in milliseconds)
RECONNECT_TIMEOUT=5000
# Max Reconnect Attempts
MAX_RECONNECT_ATTEMPTS=3
# Max Concurrent Transcriptions
MAX_CONCURRENT_TRANSCRIPTIONS=5
# Mod Log Channel Name
MOD_LOG_CHANNEL=bad-words
Replace the placeholders (your-discord-bot-token
, your-assemblyai-api-key
, etc.) with your actual values.
Compile the TypeScript code into JavaScript:
npm run build
Run the bot using the following command:
npm start
- Invite the Bot: Invite the bot to your Discord server using the OAuth2 URL from the Discord Developer Portal.
- Join a Voice Channel: The bot will automatically join the most populated voice channel in your server.
- Monitor Voice Chat: When a user speaks, the bot will record their audio, transcribe it, and check for swear words.
- Alerts and Logs:
- If swear words are detected, the bot will send a warning to the user.
- Incidents will be logged in the specified moderation log channel (
bad-words
by default).
You can customize the bot's behavior by modifying the following environment variables in the .env
file:
Variable | Description | Default Value |
---|---|---|
DISCORD_BOT_TOKEN |
Your Discord bot token. | - |
ASSEMBLYAI_API_KEY |
Your AssemblyAI API key. | - |
SWEAR_WORDS |
Comma-separated list of swear words to detect. | badword,test,bad |
RECONNECT_TIMEOUT |
Time (in milliseconds) to wait before reconnecting to a voice channel. | 5000 |
MAX_RECONNECT_ATTEMPTS |
Maximum number of reconnect attempts. | 3 |
MAX_CONCURRENT_TRANSCRIPTIONS |
Maximum number of concurrent transcription requests. | 5 |
MOD_LOG_CHANNEL |
The name of the channel where warnings will be logged. | bad-words |
- Start the Bot:
npm start
- Build the Project:
npm run build