Configuration Guide
how to configure your self-hosted InterChat instance through environment variables and other settings.
Environment Variables
InterChat uses environment variables for configuration. Create a .env
file in the root directory of your installation with the following variables:
Required Variables
Discord Bot Configuration
Creating a Discord Application
- Go to the Discord Developer Portal
- Click "New Application" and give it a name
- Navigate to the "Bot" tab
- Click "Add Bot"
- Under the "Token" section, click "Copy" to get your bot token (used for
DISCORD_TOKEN
) - Note your Application ID from the "General Information" tab (used for
CLIENT_ID
)
Required Bot Permissions
Your bot needs the following permissions:
- Read Messages/View Channels
- Send Messages
- Manage Messages
- Embed Links
- Attach Files
- Read Message History
- Use External Emojis
- View Audit Log
- Add Reactions
- Manage Webhooks
Required Gateway Intents
In the Discord Developer Portal, under the "Bot" tab, enable:
- Server Members Intent
- Message Content Intent
Without these intents, InterChat will not function at all.
Database Configuration
InterChat uses MongoDB Atlas for its database. The DATABASE_URL
should follow this format:
Database Setup
After setting up your MongoDB Atlas cluster:
Redis Configuration
Redis is used for caching and real-time features. The REDIS_URL
should follow this format:
For local Redis instances without authentication, use:
Advanced Configuration
Metrics and Monitoring
InterChat supports Prometheus metrics:
To use with Grafana Cloud:
Error Tracking
For production environments, it's recommended to use Sentry for error tracking:
Custom Emojis
InterChat uses custom emojis for various features. To set up custom emojis:
- Run
npm run sync:emojis
to sync the emojis with your bot
The synced emojis can be viewed in the Discord Developer Portal under the "Emojis" tab.
Localization
InterChat supports multiple languages. Localization files are stored in the locales/
directory.
To add a new language:
Visit our Crowdin project to contribute translations. (Recommended)
Or manually, if you're familiar with YAML:
- Copy
locales/en.yml
tolocales/your_language_code.yml
- Translate the strings in the new file
- Run
npm run locale-types
to update the type definitions
Command Synchronization
After making changes to commands or updating the bot, sync the commands with Discord:
This ensures that slash commands are properly registered with Discord.
Security Considerations
When self-hosting InterChat, consider these security best practices:
- Run the bot with minimal permissions
- Enable firewall rules to restrict access to your server
- Regularly update dependencies with
npm install
- Back up your database regularly
Never share your .env
file or bot token. Anyone with your bot token can control your bot.