https://github.com/cptcr/pegasus
Official Discord bot of Hinkos Discord. Written in TypeScript with Web-UI and German support.
https://github.com/cptcr/pegasus
docker next nextauth nextjs14 postgresql prisma typescript vercel
Last synced: 6 months ago
JSON representation
Official Discord bot of Hinkos Discord. Written in TypeScript with Web-UI and German support.
- Host: GitHub
- URL: https://github.com/cptcr/pegasus
- Owner: cptcr
- Created: 2025-05-22T13:31:02.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-23T18:24:51.000Z (about 1 year ago)
- Last Synced: 2025-06-26T18:18:24.099Z (12 months ago)
- Topics: docker, next, nextauth, nextjs14, postgresql, prisma, typescript, vercel
- Language: TypeScript
- Homepage: Dashboard: http://localhost:3001
- Size: 23.5 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ Pegasus Discord Bot
๐ A Production-Ready, Feature-Rich Discord Bot Built with TypeScript
Support Server โข
Developer โข
Features โข
Installation โข
Commands
---
## ๐ Table of Contents
- [โจ Features](#-features)
- [๐ง Tech Stack](#-tech-stack)
- [๐ฆ Prerequisites](#-prerequisites)
- [๐ Installation](#-installation)
- [โ๏ธ Configuration](#-configuration)
- [๐ Commands](#-commands)
- [๐ Security Features](#-security-features)
- [๐ Internationalization](#-internationalization)
- [๐ข Deployment](#-deployment)
- [๐ค Contributing](#-contributing)
- [๐ License](#-license)
- [๐ฌ Support](#-support)
## โจ Features
### ๐ก๏ธ Advanced Moderation System
- **Comprehensive Warning System** with automation rules and thresholds
- **Multi-action Moderation** - Ban, kick, timeout with reason tracking
- **Audit Logging** - Complete action history with user tracking
- **Permission Hierarchy** - Role-based command access control
- **Blacklist System** - Developer-only user management
### ๐ฐ Full Economy System
- **Virtual Currency** with balance tracking and transactions
- **5 Gambling Games**:
- ๐ฒ Dice - Roll against the house
- ๐ช Coinflip - 50/50 chance game
- ๐ฐ Slots - Classic slot machine
- โ ๏ธ Blackjack - Full blackjack implementation
- ๐ฏ Roulette - Multiple betting options
- **Shop System** - Buy/sell items with inventory management
- **Work & Rob** - Earn money with cooldowns and protection items
- **Daily Rewards** - Streak bonuses for consecutive claims
### ๐ Advanced Giveaway System
- **Multiple Entry Methods** - Bonus entries for roles/boosters
- **Requirements System** - Role, level, or time-based requirements
- **Live Timer Updates** - Real-time countdown display
- **Automatic Winner Selection** - Fair, weighted random selection
- **Reroll Capability** - Change winners after giveaway ends
### ๐๏ธ Professional Ticket System
- **Custom Panels** - Design support panels with embeds
- **Category Management** - Organize tickets by type
- **Ticket Actions**:
- Claim - Assign ticket to staff
- Close - Close with optional reason
- Lock - Prevent user messages
- Freeze - Prevent all messages
- **Transcript Generation** - Save ticket history
- **Statistics Tracking** - Monitor support metrics
### ๐ XP & Leveling System
- **Voice & Text XP** - Earn XP through activity
- **Role Rewards** - Automatic role assignment at levels
- **Custom Rank Cards** - Personalized rank displays
- **Leaderboards** - Server-wide rankings
- **Booster Bonuses** - Extra XP for server boosters
- **Channel Multipliers** - Configure XP rates per channel
### ๐ Multi-Language Support
- **4 Languages**: English, German, Spanish, French
- **Per-User Language** - Individual language preferences
- **Localized Commands** - Command descriptions in all languages
- **Dynamic Translations** - All bot responses translated
### ๐ง Server Configuration
- **Welcome/Goodbye System** - Custom messages with embeds
- **Auto-Role Assignment** - Automatic roles for new members
- **Language Settings** - Server-wide language preference
- **XP Configuration** - Customize leveling system
- **Economy Settings** - Adjust currency and rewards
## ๐ง Tech Stack
| Technology | Purpose |
|------------|---------|
| **TypeScript 5.0** | Type-safe development with strict mode |
| **Discord.js v14** | Latest Discord API features |
| **PostgreSQL 16** | Robust relational database |
| **Drizzle ORM** | Type-safe database queries |
| **Zod** | Runtime validation and type safety |
| **i18next** | Internationalization framework |
| **Winston** | Advanced logging system |
| **Node.js 18+** | Modern JavaScript runtime |
## ๐ฆ Prerequisites
- **Node.js**: v18.0.0 or higher
- **PostgreSQL**: v14 or higher
- **npm**: v9.0.0 or higher
- **Discord Application**: [Create here](https://discord.com/developers/applications)
### Required Bot Permissions
```
- View Channels
- Send Messages
- Embed Links
- Attach Files
- Manage Messages
- Manage Roles
- Manage Channels
- Use External Emojis
- Add Reactions
- Read Message History
- Connect (for voice XP)
- Move Members
- Moderate Members
```
## ๐ Installation
### 1. Clone Repository
```bash
git clone https://github.com/cptcr/pegasus.git
cd pegasus
```
### 2. Install Dependencies
```bash
npm install
```
### 3. Database Setup
Create a PostgreSQL database:
```sql
CREATE DATABASE pegasus;
```
### 4. Environment Configuration
Create `.env` file in root directory:
```env
# Required Configuration
DISCORD_TOKEN=your_bot_token_here
DISCORD_CLIENT_ID=your_application_id_here
DATABASE_URL=postgresql://username:password@localhost:5432/pegasus
DEVELOPER_IDS=["your_discord_id_here"]
SUPPORT_SERVER_INVITE=https://discord.gg/your_invite
# Optional Configuration
NODE_ENV=development
DEFAULT_LANGUAGE=en
LOG_LEVEL=info
# Security (Generate a 32-character key)
ENCRYPTION_KEY=your_32_character_encryption_key_here
# Optional Services
REDIS_URL=redis://localhost:6379
STEAM_API_KEY=your_steam_api_key
```
### 5. Build Project
```bash
npm run build
```
### 6. Start Bot
```bash
# Production
npm start
# Development (with auto-reload)
npm run dev
```
## โ๏ธ Configuration
### First-Time Setup
After inviting the bot to your server:
1. **Set Server Language**
```
/config lang
```
2. **Configure XP System**
```
/config xp
```
3. **Setup Economy**
```
/config eco
```
4. **Configure Welcome Messages**
```
/config welcome
```
5. **Setup Auto-Roles**
```
/config autorole
```
### Database Tables (Auto-Created)
The bot automatically creates all required tables on first startup:
- `users` - User profiles and preferences
- `guilds` - Server configurations
- `guild_settings` - Detailed server settings
- `members` - Per-server user data
- `warnings` - Warning records
- `warning_automations` - Automated moderation rules
- `economy_balances` - User balances
- `economy_transactions` - Transaction history
- `economy_shop_items` - Shop inventory
- `tickets` - Support tickets
- `ticket_panels` - Ticket panel configurations
- `giveaways` - Giveaway data
- `giveaway_entries` - User entries
- `user_xp` - XP and level data
- `xp_rewards` - Level role rewards
- `audit_logs` - Complete action history
## ๐ Commands
### ๐ก๏ธ Moderation Commands
| Command | Description | Permission |
|---------|-------------|-----------|
| `/warn create` | Issue warning with title, description, level | Moderate Members |
| `/warn edit` | Edit existing warning via modal | Moderate Members |
| `/warn lookup` | View specific warning by ID | Moderate Members |
| `/warn view` | View all warnings for a user | Moderate Members |
| `/warn automation create` | Setup automated actions | Administrator |
| `/warn automation view` | List all automations | Administrator |
| `/warn automation delete` | Remove automation | Administrator |
| `/moderation ban` | Ban user with optional reason | Ban Members |
| `/moderation kick` | Kick user with optional reason | Kick Members |
| `/moderation timeout` | Timeout user for duration | Moderate Members |
| `/moderation mute` | Apply the server mute role (optional duration) | Moderate Members |
| `/moderation unmute` | Remove the mute role from a user | Moderate Members |
| `/moderation unban ` | Unban a user by ID | Ban Members |
| `/moderation purge ` | Bulk delete recent messages | Manage Messages |
| `/moderation lock [channel]` | Lock a text channel for @everyone | Manage Channels |
| `/moderation unlock [channel]` | Unlock a previously locked channel | Manage Channels |
| `/moderation slowmode ` | Set channel slowmode (0 disables) | Manage Channels |
| `/moderation modlog [user]` | Display recent moderation cases | Moderate Members |
| `/moderation case view ` | View a specific moderation case | Moderate Members |
| `/moderation case delete ` | Delete a moderation case | Manage Guild |
| `/moderation reset-xp` | Reset user's XP to 0 | Manage Guild |
### ๐ฐ Economy Commands
| Command | Description | Cooldown |
|---------|-------------|----------|
| `/balance [user]` | Check balance | None |
| `/daily` | Claim daily reward (100-500) | 24 hours |
| `/work` | Work for money (50-200) | 1 hour |
| `/rob ` | Attempt to rob another user | 24 hours |
| `/shop view` | Browse available items | None |
| `/shop buy ` | Purchase an item | None |
| `/shop inventory` | View your items | None |
| `/gamble dice ` | Roll dice (1-6 vs dealer) | None |
| `/gamble coinflip ` | Flip coin (heads/tails) | None |
| `/gamble slots ` | Play slot machine | None |
| `/gamble blackjack ` | Play blackjack | None |
| `/gamble roulette ` | Play roulette | None |
### ๐ Giveaway Commands
| Command | Description | Permission |
|---------|-------------|-----------|
| `/gw start` | Advanced giveaway with modal | Manage Guild |
| `/gw simple` | Quick giveaway setup | Manage Guild |
| `/gw end ` | Manually end giveaway | Manage Guild |
| `/gw reroll ` | Select new winners | Manage Guild |
| `/gw configure ` | Edit active giveaway | Manage Guild |
### ๐๏ธ Ticket Commands
| Command | Description | Permission |
|---------|-------------|-----------|
| `/ticket panel create` | Design ticket panel | Manage Guild |
| `/ticket panel load ` | Send panel to channel | Manage Guild |
| `/ticket panel delete ` | Remove panel | Manage Guild |
| `/ticket panel list` | View all panels | Manage Guild |
| `/ticket claim` | Claim ticket | Support Role |
| `/ticket close [reason]` | Close ticket | Support Role |
| `/ticket stats` | View statistics | Manage Guild |
### ๐ XP Commands
| Command | Description |
|---------|-------------|
| `/xp rank [user]` | View rank card |
| `/xp leaderboard` | Top 10 users |
| `/xp configuration` | View XP settings |
| `/xp card` | Customize rank card |
### โ๏ธ Configuration Commands
| Command | Description | Permission |
|---------|-------------|-----------|
| `/config xp` | XP system settings | Manage Guild |
| `/config eco` | Economy settings | Manage Guild |
| `/config lang` | Server language | Manage Guild |
| `/config welcome` | Welcome messages | Manage Guild |
| `/config goodbye` | Goodbye messages | Manage Guild |
| `/config autorole` | Auto-role setup | Manage Guild |
### ๐ง Utility Commands
| Command | Description |
|---------|-------------|
| `/utils help [command]` | Dynamic help menu |
| `/utils avatar [user]` | Display avatar |
| `/utils banner [user]` | Display banner |
| `/utils steam ` | Steam profile info |
| `/utils userinfo [user]` | User details |
| `/utils whois ` | Detailed lookup |
| `/utils roleinfo ` | Role information |
| `/utils serverinfo` | Server statistics |
| `/utils support` | Support server link |
| `/utils stats` | Bot statistics |
| `/ping` | Check latency |
### ๐ฎ Fun Commands
| Command | Description |
|---------|-------------|
| `/fun meme` | Random meme |
| `/fun fact` | Fun fact |
| `/fun joke` | Random joke |
| `/fun quote` | Inspirational quote |
| `/fun dadjoke` | Dad joke |
### ๐ Language Commands
| Command | Description |
|---------|-------------|
| `/language available` | List languages |
| `/language current` | Your language |
| `/language set ` | Change language |
### ๐ Admin Commands
| Command | Description | Permission |
|---------|-------------|-----------|
| `/blacklist user ` | Blacklist user | Developer Only |
| `/blacklist view` | View blacklist | Developer Only |
| `/blacklist remove ` | Unblacklist | Developer Only |
## ๐ Security Features
### Input Validation
- **Zod Schemas** - Runtime validation for all inputs
- **SQL Injection Prevention** - Parameterized queries
- **XSS Protection** - Input sanitization
- **Rate Limiting** - Per-user and global limits
### Permission System
- **Hierarchical Permissions** - Role-based access
- **Developer Override** - Emergency access
- **Audit Logging** - Track all actions
- **Blacklist System** - Block malicious users
### Data Protection
- **Encryption** - Sensitive data encryption
- **Secure Tokens** - Environment variable storage
- **HTTPS Only** - Secure API communications
- **Privacy Compliance** - User data protection
## ๐ Internationalization
### Supported Languages
- ๐ฌ๐ง **English** (en) - Default
- ๐ฉ๐ช **German** (de) - Deutsch
- ๐ช๐ธ **Spanish** (es) - Espaรฑol
- ๐ซ๐ท **French** (fr) - Franรงais
### Translation Coverage
- โ
All command descriptions
- โ
All bot responses
- โ
Error messages
- โ
Embed content
- โ
Button/Modal text
## ๐ข Deployment
### Using Docker
```dockerfile
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --production
COPY . .
RUN npm run build
CMD ["npm", "start"]
```
### Using PM2
```bash
npm install -g pm2
pm2 start dist/index.js --name pegasus
pm2 save
pm2 startup
```
### Hosting Recommendations
- **VPS**: DigitalOcean, Linode, Vultr
- **Cloud**: AWS EC2, Google Cloud, Azure
- **Managed**: Railway, Heroku, Render
## ๐ค Contributing
We welcome contributions! Please follow these steps:
1. Fork the repository
2. Create feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit changes (`git commit -m 'Add AmazingFeature'`)
4. Push to branch (`git push origin feature/AmazingFeature`)
5. Open Pull Request
### Code Standards
- TypeScript strict mode enabled
- No production comments
- Comprehensive error handling
- Unit tests for new features
## ๐ License
This project is licensed under the MIT License - see [LICENSE](LICENSE) file.
## ๐ฌ Support
- **Discord Server**: [discord.gg/vaultscope](https://discord.gg/vaultscope)
- **Developer**: [cptcr.dev](https://cptcr.dev)
- **GitHub Issues**: [Report bugs](https://github.com/cptcr/pegasus/issues)
- **Email**: support@cptcr.dev
## ๐ Acknowledgments
- Discord.js team for the excellent library
- PostgreSQL team for the robust database
- All contributors and community members
- Open source projects that made this possible
---