Overview
AutoResponse uses environment variables for configuration. These are stored in a.env file in the project root directory.
Required Variables
These environment variables are essential for the bot to function:TOKEN
Type:string (required)
Usage: src/client.js:24
Your Discord bot token from the Discord Developer Portal.
How to Get Your Token
How to Get Your Token
- Go to the Discord Developer Portal
- Select your application
- Navigate to the Bot section
- Click Reset Token and copy the token
OWNERID
Type:string (required)
Usage: src/events/messageCreate.js:123
The Discord user ID of the bot owner. This grants access to owner-only message commands.
How to Find Your User ID
How to Find Your User ID
- Enable Developer Mode in Discord:
- User Settings > Advanced > Developer Mode (toggle on)
- Right-click your username anywhere in Discord
- Click Copy User ID
PREFIX
Type:string (required)
Usage: src/events/messageCreate.js:124
The prefix for message-based owner commands.
Only the bot owner (specified by
OWNERID) can use message commands with this prefix.Optional Variables
These variables enable additional features but are not required for basic operation:Email Configuration
Usage:utils/sendEmail.js:9
For sending error notifications via email (SendGrid):
APPID
Type:string (optional)
Usage: utils/updateEmojis.js:7
Your Discord application ID, used for updating custom emojis.
How to Find Your Application ID
How to Find Your Application ID
- Go to the Discord Developer Portal
- Select your application
- Copy the Application ID from the General Information page
CLARIFAI_PAT
Type:string (optional)
Usage: utils/scanImage.js:1
Personal Access Token for Clarifai API (image content moderation).
This is used for image scanning and moderation features. If not configured, image moderation will be disabled.
.env.example Template
Create a.env file in your project root with the following structure:
Loading Environment Variables
Environment variables are automatically loaded using thedotenv package:
src/client.js:14 when the bot initializes.
Environment Variable Validation
Test Configuration
Start your bot and check the console for any errors related to missing variables:
Security Best Practices
.gitignore Configuration
Ensure your.gitignore includes:
Token Rotation
If your bot token is compromised:Troubleshooting
Bot Won't Start - Invalid Token
Bot Won't Start - Invalid Token
Error: “An invalid token was provided”Solution:
- Verify your
TOKENin.envis correct - Ensure there are no extra spaces or quotes
- Try regenerating the token in Discord Developer Portal
- Make sure the
.envfile is in the project root
Owner Commands Not Working
Owner Commands Not Working
Issue: Owner commands with prefix don’t workSolution:
- Verify your
OWNERIDmatches your Discord user ID exactly - Check that
PREFIXis set correctly - Ensure you’re using the prefix in messages (e.g.,
!command) - Check console logs for permission errors
Environment Variables Not Loading
Environment Variables Not Loading
Issue: Bot can’t read environment variablesSolution:
- Ensure
.envfile exists in project root - Check that
dotenvpackage is installed:npm install dotenv - Verify
.envfile format (no spaces around=) - Restart the bot after changing
.env
Email Notifications Not Working
Email Notifications Not Working
Issue: Not receiving error emailsSolution:
- This is optional functionality - bot works without it
- Verify all SendGrid variables are set correctly
- Check SendGrid account status and credentials
- Look for email-related errors in console logs
Development vs Production
For different environments, you can use multiple.env files:
Development
.env.development
Production
.env.production
Next Steps
After configuring your environment variables:Initial Setup
Complete the initial bot setup process
Database Structure
Learn about the bot’s database architecture
Permissions
Configure Discord permissions properly
Slash Commands
Start using bot commands