# Discord bot in an afternoon

> Build and host an AI-powered Discord bot for your server.

- Category: Build agents · Difficulty: Intermediate
- Estimated monthly cost: $25–$30/mo. Claude Pro $20 to build, Railway Hobby $5 (includes $5 usage). Bot API calls are pay-per-token on top, small with Haiku 5.5.
- Model: Claude Sonnet 5.5 to build; Claude Haiku 5.5 inside the bot
- MCP servers: none
- Last checked: 2026-10-21 · Hands-on tested: no (built from official docs)
- Canonical: https://getagentloadout.com/loadouts/discord-bot/ · JSON: https://getagentloadout.com/data/loadouts/discord-bot.json

## Tools
- [Claude Code](https://claude.com/product/claude-code): Anthropic's agentic coding tool for the terminal and IDEs. Included in paid Claude plans. Pricing: Pro $20/mo ($17/mo billed yearly; 5-hour and weekly usage limits); Max 5x $100/mo (5x Pro usage per session); Max 20x $200/mo (20x Pro usage per session). Source: https://claude.com/pricing
- [discord.js](https://discord.js.org): The standard Node.js library for Discord bots. Pricing: Open source $0/mo. Source: https://discord.js.org
- [Railway](https://railway.com): Deploy always-on services (bots, APIs, workers) from a repo. Pricing: Hobby $5/mo (Includes $5 of usage; overage billed on top); Pro $20/mo (Includes $20 of usage; unlimited workspace seats). Source: https://railway.com/pricing

## Starter prompt

```
Create a discord.js bot with slash commands /ask (answers with Claude Haiku 5.5, max 300 tokens) and /help. Add per-user rate limiting, ignore other bots, read secrets from .env, and add a Procfile or start script so it runs on Railway.
```

## Config (.env.example)

```bash
DISCORD_TOKEN=
ANTHROPIC_API_KEY=
# never commit .env
```

## Setup steps
1. Create the app in the Discord Developer Portal and copy the token.
2. Run the prompt in Claude Code.
3. Test in a private server.
4. Deploy to Railway with the env vars set.

## Why this works
A small, always-on service is exactly what Railway's Hobby plan is for.

## Watch out
Rate limit /ask or a busy server will run up your API bill.

## Unverified
- discord.js details not re-checked this cycle.

## Related loadouts
- [Build your own MCP server](https://getagentloadout.com/loadouts/build-mcp-server/)
- [Personal research agent](https://getagentloadout.com/loadouts/research-agent/)
- [Production agent in TypeScript](https://getagentloadout.com/loadouts/ts-production-agent/)

Some links may be affiliate links; it never affects rankings. Rankings are never for sale.
