The Discord bot component of the Khaxy monorepo. A feature-rich moderation and utility bot built with Discord.js v14 and TypeScript.
- Moderation Commands - Ban, kick, mute, warn, timeout, and more
- Modmail System - Private communication between users and staff
- Auto-Moderation - Automated content filtering and enforcement
- Logging - Comprehensive server event logging
- Welcome/Leave Messages - Customizable member join/leave notifications
- Role Management - Auto-roles, role rewards, and more
- Internationalization - Full support for English and Turkish
The easiest way to run the bot:
# From the monorepo root
cd Khaxy
# Create environment file
cp .env.example .env
# Edit .env with your Discord token and settings
# Start with Docker
docker compose up -d
# Or with Podman
podman compose up -d
# View logs
docker compose logs -f bot# Pull from GitHub Container Registry
docker pull ghcr.io/arsabutispik/khaxy-bot:latest# Required
DISCORD_BOT_TOKEN=your_discord_bot_token
CLIENT_ID=your_discord_application_client_id
# Optional (defaults provided)
POSTGRES_USER=khaxy
POSTGRES_PASSWORD=khaxy_password
POSTGRES_DB=khaxy- Node.js v22.0.0 or higher
- pnpm package manager
- PostgreSQL database
- A Discord Application with a bot token
-
Clone the repository (if you haven't already)
git clone https://github.com/Arsabutispik/Khaxy.git cd Khaxy -
Install dependencies from the root of the monorepo
pnpm install
-
Set up environment variables
All environment variables are configured in a single
.envfile at the root of the monorepo. See the root README for the full list of required variables.The bot uses these variables:
Variable Description TOKENDiscord bot token GUILD_IDGuild ID for development/testing CLIENT_IDDiscord application client ID DOCS_URLURL for bot documentation DATABASE_URLPostgreSQL connection string INTERNAL_API_KEYSecret key for bot-web communication -
Run database migrations
pnpm db:migrate
-
Configure the bot
Copy the example configuration file:
cd apps/bot cp config.example.toml config.tomlEdit
config.tomlwith your settings:- Custom emoji IDs (or use the fallback emojis)
- Bot activity messages
- Logging configuration (webhook, file, console)
-
Deploy slash commands
pnpm run deploy-commands
-
Start the bot
# Development mode pnpm run dev # Production mode pnpm run build pnpm run start
You can also run the bot from the monorepo root:
# Start all apps (bot + web)
pnpm dev
# Or run just the bot
pnpm -F khaxyrewrite devThe bot uses a multi-stage Dockerfile for optimized image size (~360MB):
| Stage | Purpose |
|---|---|
builder |
Install deps, generate Prisma, build TypeScript |
deps |
Create flat node_modules with npm |
runner |
Minimal production image |
- Compiled JavaScript code
- Production dependencies
- Prisma client
- Localization files
- Config template
- Source TypeScript files
- Development dependencies
.envfiles or secrets- Discord tokens
apps/bot/
├── src/
│ ├── index.ts # Bot entry point
│ ├── api/ # Internal API server
│ ├── config-functions/ # Configuration handlers
│ ├── constants/ # Constants and enums
│ ├── events/ # Discord event handlers
│ ├── i18n/ # Internationalization setup
│ ├── lib/ # Core libraries and utilities
│ ├── slash-commands/ # Slash command definitions
│ ├── types/ # TypeScript type definitions
│ └── utils/ # Utility functions
├── locales/ # Translation files
│ ├── en-GB/ # English translations
│ └── tr-TR/ # Turkish translations
├── scripts/ # Build and utility scripts
├── config.toml # Bot configuration
├── Dockerfile # Container build file
└── package.json
| Command | Description |
|---|---|
pnpm dev |
Build and run in development mode |
pnpm build |
Build for production |
pnpm start |
Start the production build |
pnpm deploy-commands |
Deploy slash commands to Discord |
pnpm lint |
Run ESLint |
pnpm type-check |
Run TypeScript type checking |
pnpm validate-translations |
Validate translation files |
The config.toml file contains bot-specific settings:
- Emojis - Custom emoji IDs with fallbacks for servers without the emojis
- Activity - Bot status messages that rotate automatically
- Logging - Configure webhook, file, and console logging
The bot supports multiple languages. Translation files are located in the locales/ directory:
en-GB/- English (default)tr-TR/- Turkish
Each language folder contains YAML files for different translation categories:
commands.yml- Command responsesevents.yml- Event messagespermissions.yml- Permission names- And more...
This project is licensed under the GNU GPLv3 License.