https://github.com/enum314/nemesis
Nemesis is a modern Discord bot template designed to streamline bot development with best practices, advanced infrastructure, and seamless deployment. Built with Node.js 22, Discord.js, and PNPM 10, it includes Docker, CI/CD workflows, and Pterodactyl integration for easy hosting.
https://github.com/enum314/nemesis
best-practices bot-template cicd discord-bot discordjs docker nodejs pnpm pterodactyl-egg scalable-infrastructure
Last synced: 9 months ago
JSON representation
Nemesis is a modern Discord bot template designed to streamline bot development with best practices, advanced infrastructure, and seamless deployment. Built with Node.js 22, Discord.js, and PNPM 10, it includes Docker, CI/CD workflows, and Pterodactyl integration for easy hosting.
- Host: GitHub
- URL: https://github.com/enum314/nemesis
- Owner: enum314
- License: mit
- Created: 2024-12-26T13:07:43.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-16T11:51:15.000Z (9 months ago)
- Last Synced: 2025-04-16T12:26:32.420Z (9 months ago)
- Topics: best-practices, bot-template, cicd, discord-bot, discordjs, docker, nodejs, pnpm, pterodactyl-egg, scalable-infrastructure
- Language: TypeScript
- Homepage:
- Size: 272 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nemesis
A modern Discord bot template designed to jumpstart your bot development with best practices and ready-to-use infrastructure. While primarily focused on Discord bots, Nemesis can also serve as a foundation for any Node.js application.
## ๐ About This Template
This is a template repository that provides a solid foundation for building modern Discord bots and Node.js applications. It's designed to be forked or used as a starting point for new projects, saving you hours of initial setup and configuration.
The template offers:
- **Discord.js integration** with advanced sharding and bot framework
- **Ready-to-use infrastructure** with Docker, CI/CD workflows, and deployment scripts
- **Modern tech stack** with Node.js 22 and PNPM 10
- **Development best practices** baked in from the start
- **Production-ready configuration** for immediate deployment
- **Pterodactyl integration** for easy hosting on game server panels
## ๐ Prerequisites
- [Node.js](https://nodejs.org/) v22 or later
- [PNPM](https://pnpm.io/) v10 or later
- [Docker](https://www.docker.com/) and [Docker Compose](https://docs.docker.com/compose/) (optional, for containerized development)
- [Git](https://git-scm.com/)
## ๐ ๏ธ Getting Started
### Using This Template
```bash
# Clone the template (or use GitHub's "Use this template" button)
git clone https://github.com/enum314/nemesis.git my-new-project
cd my-new-project
# Customize for your project
# - Update package.json with your project details
# - Modify .env.example for your environment variables
# - Customize the Dockerfile if needed
# - Update this README!
# Install dependencies
pnpm install
# Start development server
pnpm dev
```
### Local Development
```bash
# Start development environment
pnpm dev
# OR with Docker
docker-compose up app-dev
```
### Production Environment
```bash
# Start production environment with Docker
docker-compose up app-prod
```
## ๐ข Deployment Options
### 1. Server Deployment with Script
This template includes a deployment script that pulls directly from GitHub:
```bash
# First-time deployment
./deploy.sh --first-run --path /opt/nemesis
# Update existing deployment
./deploy.sh --update --path /opt/nemesis
# Specify a different GitHub repository
./deploy.sh --first-run --github-user username --repository repo-name --path /opt/nemesis
# For private repositories, include a personal access token
./deploy.sh --first-run --github-user username --repository repo-name --token YOUR_TOKEN --path /opt/nemesis
```
The deployment script supports various options:
```bash
Usage: deploy.sh [OPTIONS]
Options:
--github-user USER GitHub username (default: enum314)
--repository REPO Repository name (default: nemesis)
--token TOKEN GitHub personal access token for private repos
--branch NAME Branch to deploy (default: main)
--path PATH Installation path (default: /opt/nemesis)
--first-run Perform first-time setup
--force-rebuild Force rebuild of Docker containers
--show-logs Show Docker logs after deployment
--update Update existing deployment
--help Show this help message
```
### 2. Pterodactyl Panel Deployment
The template includes Pterodactyl egg files for deployment on Pterodactyl game server panels:
- `egg-nemesis.json` - JSON format egg for Pterodactyl
- `egg-nemesis.yml` - YAML format egg for Pterodactyl
#### How to Use the Pterodactyl Egg:
1. **Import to Pterodactyl Panel**:
- Log in to your Pterodactyl admin panel
- Go to Nests > Import Egg
- Upload the `egg-nemesis.json` file
2. **Create a New Server**:
- In the Pterodactyl admin panel, create a new server
- Select the Nemesis egg from the list
- Configure server settings including port allocations and resources
3. **Configurable Options**:
- **Auto Update**: Automatically pull changes on startup
- **Node Environment**: Choose between production, development, staging, or test
- **Additional Packages**: Install extra Node.js packages if needed
- **Wipe Directory**: Option to clean installation directory
- **Startup Command**: Customize how the application starts
- **GitHub Repository Settings**:
- **GitHub Username**: Username of the repository owner
- **GitHub Repository**: Name of the repository to clone
- **GitHub Branch**: Branch to use (default: main)
- **GitHub Personal Access Token**: For private repositories (optional)
4. **After Installation**:
- The server will automatically install your project from the specified GitHub repository
- It will configure the correct port in .env
- The server will build and start automatically
The deployment script handles:
- Environment setup
- Pulling latest changes from GitHub
- Building and starting Docker containers
- Intelligent rebuilding (only when needed)
- Status checking and error reporting
## ๐๏ธ Template Structure
```
nemesis/
โโโ .github/workflows/ # GitHub Actions CI/CD configurations
โโโ src/ # Application source code
โโโ .dockerignore # Files to exclude from Docker build
โโโ .env.example # Example environment variables
โโโ Dockerfile # Docker configuration
โโโ docker-compose.yml # Docker Compose configuration
โโโ deploy.sh # Deployment script
โโโ egg-nemesis.json # Pterodactyl egg (JSON format)
โโโ egg-nemesis.yml # Pterodactyl egg (YAML format)
โโโ package.json # Project metadata and scripts
โโโ pnpm-lock.yaml # Lock file for dependencies
โโโ tsconfig.json # TypeScript configuration
```
## ๐ณ Docker
This project includes a multi-stage Dockerfile and Docker Compose configuration:
### Development
```bash
docker-compose up app-dev
```
- Hot reload enabled
- Source code mounted as a volume
- Running on port 3001
- Development dependencies included
### Production
```bash
docker-compose up app-prod
```
- Optimized build with minimal dependencies
- Running on port 3001
- Production-ready configuration
### Building Images Manually
```bash
# Build development image
docker build --target development -t nemesis-dev .
# Build production image
docker build --target production -t nemesis-prod .
```
## ๐ Available Scripts
- `pnpm dev` - Start development server
- `pnpm build` - Build for production
- `pnpm start` - Start production server
- `pnpm test` - Run tests and build
- `pnpm lint` - Check for code style issues
- `pnpm v:patch` - Version bump patch (0.0.x)
- `pnpm v:minor` - Version bump minor (0.x.0)
- `pnpm v:major` - Version bump major (x.0.0)
## ๐ค Discord Bot Sharding
This template includes support for Discord.js sharding, which helps distribute your bot's load across multiple processes when it grows to serve more guilds.
### What is Sharding?
Discord requires sharding for bots in 2,500+ guilds. Sharding splits your bot into multiple processes, each handling a portion of the guilds, which:
- Reduces memory usage and CPU load per process
- Improves performance by distributing workload
- Is required by Discord for larger bots
### Using Sharding
Sharding can be enabled/disabled through:
**Environment Variables**:
- `ENABLE_SHARDING`: Set to "true" to enable sharding
- `TOTAL_SHARDS`: Number of shards to spawn, or "auto" to let Discord.js decide
You can enable sharding by setting these environment variables before starting your bot:
```bash
# Enable sharding with environment variables
ENABLE_SHARDING=true node .
# Or with a specific number of shards
ENABLE_SHARDING=true TOTAL_SHARDS=2 node .
```
This approach gives you more flexibility since it doesn't rely on predefined scripts. Instead, you can control sharding directly through environment variables when starting the bot. This keeps things simpler and gives you more control over the configuration.
Let me know if you'd prefer a different approach to enabling/disabling sharding in your bot!
## ๐ข CI/CD
The template includes GitHub workflows for:
- **PR Staging**: Runs tests, lint checks, and builds on pull requests
- **Staging**: Runs tests and lint checks when merging to main
## ๐ก๏ธ Environment Variables
Copy `.env.example` to `.env` and adjust the variables as needed:
```bash
cp .env.example .env
```
Required environment variables:
- `PORT`: Application port (default: 3001)
- Other variables as specified in `.env.example`
## ๐งช Testing
```bash
# Run tests
pnpm test
# Run linting
pnpm lint
```
## ๐ License
This template is licensed under the MIT License - see the LICENSE file for details.
## ๐ฅ Customizing This Template
1. Replace this README with information specific to your project
2. Update package.json with your project details
3. Customize the Docker setup if needed
4. Update environment variables in .env.example
5. Add your application code to the src directory