Quick Start
Get Discord Forum API running locally in just a few minutes.
Installation
-
Clone the repository
Terminal window git clone https://github.com/KevinTrinh1227/discord-forum-api.gitcd discord-forum-api -
Install dependencies
Terminal window pnpm install -
Configure environment
Terminal window cp .env.example .env -
Edit
.envwith your Discord credentials:# RequiredDISCORD_TOKEN=your_bot_token_hereDISCORD_CLIENT_ID=your_application_id_here# Optional (for OAuth)DISCORD_CLIENT_SECRET=your_client_secret_here -
Initialize the database
Terminal window pnpm db:push -
Start development servers
Terminal window pnpm dev
That’s it! The bot will connect to Discord and the API will be available at http://localhost:3000.
What’s Running?
After pnpm dev, you have:
| Service | URL/Status | Purpose |
|---|---|---|
| Bot | Connected to Discord | Syncs forum content |
| API | http://localhost:3000 | REST endpoints |
| Database | ./data/discord-forum.db | SQLite storage |
Verify It’s Working
Check API health
curl http://localhost:3000/healthExpected response:
{ "status": "ok", "timestamp": "2024-01-15T12:00:00.000Z"}Check bot connection
Look for this in your terminal:
[INFO] Logged in as YourBot#1234[INFO] Connected to X guildsAdd Bot to Your Server
If you haven’t already, invite the bot to your Discord server:
- Go to Discord Developer Portal
- Select your application → OAuth2 → URL Generator
- Select scopes:
bot,applications.commands - Select permissions:
View Channels,Read Message History - Copy and open the generated URL
Initial Sync
When the bot joins a server, it automatically:
- Syncs server metadata (name, icon, member count)
- Discovers all forum channels
- Syncs existing threads and messages
For large servers, initial sync may take a few minutes. You can monitor progress in the console logs.
Project Structure
discord-forum-api/├── packages/│ ├── api/ # REST API (Hono)│ ├── bot/ # Discord bot (discord.js)│ └── db/ # Database (Drizzle ORM)├── data/ # SQLite database file├── .env # Your configuration└── package.json # Root workspaceAvailable Commands
| Command | Description |
|---|---|
pnpm dev | Start all services in watch mode |
pnpm build | Build all packages |
pnpm db:studio | Open Drizzle Studio (database GUI) |
pnpm db:push | Push schema changes to database |
pnpm lint | Run linting |
pnpm test | Run tests |
Next Steps
Now that you’re running, try:
Troubleshooting
”Cannot find module” errors
Run pnpm build to compile TypeScript:
pnpm buildpnpm devBot not connecting
- Verify
DISCORD_TOKENis correct - Check token hasn’t expired (regenerate in Developer Portal if needed)
- Ensure bot has proper intents enabled
No threads syncing
- Verify the bot can see your forum channels
- Check that Message Content Intent is enabled in Developer Portal
- Look for error messages in console
See the Discord Bot Setup troubleshooting section for more help.