A feature-rich Discord bot for Arizona RP community with economy system, moderation tools, forum integration, and much more.
| Project | Status | |
|---|---|---|
| Tech Stack | ||
| Meta |
- π Table of Contents
- π Tech Stack
- π¦ Requirements
- π Installation
- βοΈ Configuration
- ποΈ Database Migrations
- π¨βπ» Development
- π Project Structure
- π License
- Python 3.13
- discord.py: Discord API wrapper
- PostgreSQL 16: Database with asyncpg driver
- SQLAlchemy 2.0: Async ORM
- Alembic: Database migrations
- Pydantic: Settings management and validation
- Docker: Containerized deployment
- uv: Fast Python package installer
- Docker 20.10+
- Docker Compose 2.0+
- Python 3.13+
- PostgreSQL 16+
- UV package manager (or pip)
- Git
- Clone the repository
git clone https://github.com/nightcore-team/nightcore.git
cd nightcore- Create environment file
cp .env.example .env-
Configure environment variables (see Configuration)
-
Build and start containers
docker-compose up --buildThe bot will automatically:
- Build the Docker image
- Start PostgreSQL database
- Run database migrations
- Launch the bot
To run in detached mode:
docker-compose up -dTo stop the bot:
docker-compose down- Clone the repository
git clone https://github.com/nightcore-team/nightcore.git
cd nightcore- Install UV package manager (if not installed)
curl -LsSf https://astral.sh/uv/install.sh | sh- Create virtual environment and install dependencies
uv sync- Set up PostgreSQL database
# Create database
psql -U postgres
CREATE DATABASE database;
CREATE USER user WITH PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE database TO user;
\q- Create environment file
cp .env.example .env-
Configure environment variables (see Configuration)
-
Run database migrations
uv run alembic upgrade head- Start the bot
uv run python main.pyCreate a .env file in the root directory with the following variables:
# Discord Bot
BOT_TOKEN=discord_bot_token
# PostgreSQL Database
POSTGRES_USER=user
POSTGRES_PASSWORD=password
POSTGRES_HOST=host # Use 'localhost' for local setup
POSTGRES_PORT=port
POSTGRES_DB=database
# Alternative: Use full database URI instead of individual fields
# POSTGRES_DATABASE_URI=postgresql+asyncpg://user:password@host:port/database
# Forum API Integration
FORUM_API_URL=https://forum.arzguard.com/api
FORUM_API_KEY=your_forum_api_key# Bot Configuration
EMBED_DESCRIPTION_LIMIT=4096
VIEW_V2_DESCRIPTION_LIMIT=3000
VIEW_V2_COMPONENTS_LIMIT=40
DELETE_MESSAGES_SECONDS=604800
VOTEBAN_ATTACHMENTS_LIMIT=7
CLOSED_TICKET_ALIVE_HOURS=48
ROLE_REQUESTS_ALIVE_HOURS=2
CASE_REWARDS_LIMIT=30
MAX_CUSTOM_REWARD_SIZE=100
BUG_REPORT_CHANNEL_ID=1442803332233171088
DISABLE_FORUM_TASK=false
# Developer User IDs (comma-separated)
DEVELOPER_IDS=1280700292530176131,566255833684508672,451359852418039808
# Database Connection Pool
POSTGRES_ECHO=false
POSTGRES_ECHO_POOL=true
POSTGRES_POOL_MAX_OVERFLOW=30
POSTGRES_POOL_SIZE=10
POSTGRES_POOL_TIMEOUT=0
POSTGRES_POOL_PRE_PING=true- Go to Discord Developer Portal
- Create a new application or select existing one
- Go to "Bot" section
- Click "Reset Token" and copy the token
- Enable required privileged intents:
- Presence Intent
- Server Members Intent
- Message Content Intent
The project uses Alembic for database migrations.
make migration
# or manually:
alembic revision --autogenerate -m "Your migration message"make migrate
# or manually:
alembic upgrade headalembic downgrade -1alembic historyThe project uses Ruff for linting and formatting:
# Check code
uv run ruff check .
# Format code
uv run ruff format .
# Fix auto-fixable issues
uv run ruff check --fix .Check pyproject.toml for
ruffconfiguration
For development, you can mount local files in Docker:
# Already configured in docker-compose.yml
volumes:
- ./src/:/app/src/
- ./main.py:/app/main.pyThis allows live code reloading without rebuilding the container.
nightcore/
βββ src/
β βββ __init__.py
β βββ config/ # Global configuration
β β βββ config.py # Main config composition
β β βββ env.py # Base environment settings
β βββ infra/ # Infrastructure layer
β β βββ api/ # External APIs
β β β βββ forum/ # NightForo API client
β β β β βββ ...
β β βββ db/ # Database layer
β β βββ config.py # Database configuration
β β βββ operations.py # Common DB operations
β β βββ session.py # Session management
β β βββ uow.py # Unit of Work pattern
β β βββ utils.py # Database utilities
β β βββ models/ # SQLAlchemy models
β βββ nightcore/ # Bot core
β β βββ bot.py # Bot class
β β βββ config.py # Bot configuration
β β βββ exceptions.py # Custom exceptions
β β βββ setup.py # Setup bot instance and modules to load
β β βββ components/ # Reusable global UI components
β β β βββ __init__.py
β β β βββ embed/ # embeds
β β β βββ v2/ # v2 (modals, views)
β β βββ events/ # Discord event handlers
β β β βββ error.py # Error handling
β β β βββ interaction.py # Interaction events
β β β βββ channel/ # Channel events
β β β βββ dto/ # Event DTOs
β β β βββ member/ # Member events (join, leave, etc.)
β β β βββ message/ # Message events
β β β βββ reaction/ # Reaction events
β β β βββ role/ # Role events
β β β βββ voice/ # Voice state events
β β βββ features/ # Feature modules
β β β βββ clans/ # Clan management system
β β β βββ compbuilder/ # Component builder
β β β βββ config/ # Bot configuration commands
β β β βββ economy/ # Economy & casino system
β β β βββ faq/ # FAQ system
β β β βββ forum/ # Forum integration
β β β βββ meta/ # Meta commands (info, stats)
β β β βββ moderation/ # Moderation tools
β β β βββ private_rooms/ # Private voice rooms
β β β βββ proposals/ # Community voting system
β β β βββ role_requests/ # Role request system
β β β βββ system/ # System commands
β β β βββ tickets/ # Support ticket system
β β βββ services/ # Business logic services
β β β βββ ...
β β βββ tasks/ # Background tasks
β β β βββ ...
β β βββ utils/ # Bot utilities
β β βββ __init__.py
β β βββ ...
β β βββ field_validators/ # Field validation utilities
β β βββ permissions/ # Permission helpers
β β βββ transformers/ # Command transformers
β βββ utils/ # Shared utilities
β βββ logging/ # Logging configuration
β βββ config.py # Logging config
β βββ setup.py # Logging setup
βββ migrations/ # Alembic database migrations
β βββ drop_structure.sql # Drop all triggers and functions
β βββ env.py # Alembic environment
β βββ README # Alembic readme
β βββ script.py.mako # Migration template
β βββ structure.sql # Full DB triggers and functions structure
β βββ versions/ # Migration versions
β βββ ...
βββ docker/ # Docker configuration
β βββ docker-entrypoint.sh # Container entrypoint script
βββ main.py # Application entry point
βββ pyproject.toml # Project metadata & dependencies # rules
βββ docker-compose.yml # Docker orchestration
βββ Dockerfile # Docker image definition
βββ alembic.ini # Alembic configuration
βββ Makefile # Common development commands (only migrations)
βββ LICENSE # License file
βββ README.md # This file
This project is licensed under the terms specified in the LICENSE file.