Overview
This guide walks you through setting up AutoResponse on your own server. Self-hosting gives you full control over the bot’s behavior, data storage, and deployment environment.AutoResponse requires Node.js and uses SQLite for data storage, making it lightweight and easy to deploy on most systems.
Prerequisites
System Requirements
- Node.js 16.x or higher
- npm or yarn package manager
- Git for cloning the repository
- At least 100MB free disk space
- Stable internet connection
Discord Developer Account
You’ll need access to the Discord Developer Portal to create a bot application:
- Visit Discord Developer Portal
- Sign in with your Discord account
Creating a Discord Bot
Create Application
- Go to Discord Developer Portal
- Click “New Application”
- Enter a name (e.g., “AutoResponse”)
- Accept the Developer Terms of Service
- Click “Create”
Configure Bot
- Navigate to the “Bot” section in the left sidebar
- Click “Add Bot”
- Click “Reset Token” and copy your bot token
- Under Privileged Gateway Intents, enable:
- ✅ Message Content Intent
- ✅ Server Members Intent
- ✅ Presence Intent
Generate Invite Link
- Go to the “OAuth2” → “URL Generator” section
- Under Scopes, select:
- ✅
bot - ✅
applications.commands
- ✅
- Under Bot Permissions, select:
- ✅ Read Messages/View Channels
- ✅ Send Messages
- ✅ Read Message History
- ✅ Add Reactions
- ✅ Use Slash Commands
- Copy the generated URL at the bottom
- Open the URL in your browser and invite the bot to your server
Installation Steps
Install Dependencies
Install required Node.js packages:This installs all dependencies from
package.json:Configure Environment Variables
Create a Add your configuration:
.env file in the project root directory:How to find your Discord User ID
How to find your Discord 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”
- Paste into the
OWNERIDfield
Initialize Data Directory
Create the data directory structure:The bot will automatically create these database files on first run:
data/{serverId}.db- Per-server configurationdata/optoutlist.db- User opt-out listdata/replyCooldowns.db- Reply cooldown trackingdata/disabledEvents.json- Optional event configuration
Running the Bot
Start the Bot
- Linux/macOS
- Windows
Verify Startup
You should see output similar to:The bot logs all activity with color-coded output using the
colors package. Check the console for message events, errors, and command execution.Understanding the Architecture
Project Structure
Core Components
Client Initialization (src/client.js)
Client Initialization (src/client.js)
The main entry point creates the Discord client with required intents:
- Loads all event handlers from
src/events/ - Registers slash commands
- Sets bot presence every 15 seconds
- Starts express server for health checks
Message Handler (src/events/messageCreate.js)
Message Handler (src/events/messageCreate.js)
Processes every message in monitored channels:Key features:
- Filters out bots, webhooks, and system messages
- Checks opt-out list
- Manages probability system
- Downloads attachments to
data/media/ - Tracks cooldowns
Database Schema
Database Schema
Each server gets an SQLite database with these tables:replyChannels table:phrases table:trustedRoles table:
Production Deployment
Using PM2 (Recommended)
PM2 is a production process manager for Node.js applications:Using systemd
Create a systemd service file at/etc/systemd/system/autoresponse.service:
Using Docker
Create aDockerfile:
Environment Variables Reference
| Variable | Required | Description | Example |
|---|---|---|---|
TOKEN | Yes | Discord bot token from Developer Portal | MTEx... |
OWNERID | Yes | Discord user ID of the bot owner | 123456789012345678 |
PREFIX | Yes | Command prefix for owner commands | ! |
DEBUG_MODE | No | Enable verbose logging (true/false) | false |
Backup and Maintenance
Backup Database
Regularly backup yourdata/ directory:
Update Bot
View Logs
The bot uses colored console output for logging:Troubleshooting
Bot doesn't start
Bot doesn't start
Check:
- Node.js version:
node --version(should be 16+) - Dependencies installed:
npm install .envfile exists with correctTOKEN- Token is valid in Discord Developer Portal
Bot connects but commands don't work
Bot connects but commands don't work
Verify:
- Bot has slash command permission when invited
- Privileged intents enabled in Developer Portal
- Command registration completed:
- Bot has proper permissions in the channel
Database errors
Database errors
Check:
data/directory exists and is writable- SQLite3 installed correctly:
npm rebuild sqlite3 - No file permission issues:
chmod 755 data/ - Database files aren’t corrupted:
High memory usage
High memory usage
The bot stores some data in memory:
- Event handler cache
- Command collections
- Database connections
- Disable attachment downloads (comment out download logic)
- Close database connections properly
- Restart bot periodically with PM2 or cron
Security Best Practices
Protect Credentials
- Never commit
.envto version control - Use environment variables or secrets manager
- Rotate bot token if exposed
- Restrict
OWNERIDcommands to trusted users
Next Steps
Your bot is now running! Continue with:Quickstart Guide
Configure channels, add phrases, and test your first auto-reply
Advanced Features
Explore cooldowns, trusted roles, and database configuration
Getting Help
If you encounter issues:- Check console output for detailed error messages
- Review Discord Developer Portal for permission issues
- Verify
.envconfiguration matches requirements - Test with a minimal configuration first
- Check database file permissions in
data/directory