A powerful Discord bot for managing license keys and premium memberships within your Discord server.
Hey everyone! π
I want to be transparent with the Licensy community. Due to time constraints, I'm no longer able to actively maintain this bot as much as I'd like to. That's why I've decided to make the project public and open-source!
What this means:
- Pull requests are more than welcome!
- I'll still push updates when I can, even if not as frequently
- The community can help improve and maintain the bot
- Much love to all Licensy users - thank you for your support!
Want to use the official bot? π€ Invite Licensy to your server
Show your support! If you find Licensy useful, please consider starring this repository - it really helps and motivates me to keep working on the project!
Thank you for understanding and for being part of the Licensy community! π
- Features
- Prerequisites
- Installation
- Configuration
- Usage
- Commands
- Database Schema
- Contributing
- Support
- Author
- License
- License Key Management: Create, redeem, and manage license keys with expiration dates
- Role Assignment: Automatically assign roles when license keys are redeemed
- Premium System: Enhanced features for premium guilds with higher limits
- Logging System: Track license activities with customizable logging
- Database Integration: PostgreSQL database with Prisma ORM
- Cooldown System: Built-in command cooldowns to prevent spam
- Permission System: Role-based permissions for different commands
- Node.js v20.0.0 or higher
- pnpm package manager
- PostgreSQL database
- Discord Bot Token and Application
-
Clone the repository
git clone https://github.com/mathisdev7/licensy.git cd licensy -
Install dependencies
pnpm install
-
Set up environment variables
cp .env.example .env
Edit the
.envfile with your configuration:DISCORD_TOKEN=your_discord_bot_token CLIENT_ID=your_discord_client_id GUILD_ID=your_discord_guild_id DATABASE_URL=postgresql://username:password@localhost:5432/licensy environment=prod
-
Set up the database
pnpm prisma migrate deploy pnpm prisma generate
-
Start the bot
pnpm start
| Variable | Description | Required |
|---|---|---|
DISCORD_TOKEN |
Your Discord bot token | β |
CLIENT_ID |
Your Discord application client ID | β |
GUILD_ID |
Your Discord server ID (for development) | β |
DATABASE_URL |
PostgreSQL connection string | β |
environment |
Environment mode (dev, prod, debug) |
β |
Make sure your bot has the following permissions:
- Send Messages
- Use Slash Commands
- Manage Roles
- Read Message History
- Embed Links
Licensy v3 includes a robust error handling system to prevent crashes from common Discord API errors:
- Unknown Member (10007): When a user leaves the server but still has active licenses
- Unknown Guild (10004): When the bot is removed from a server
- Missing Permissions (50013): When the bot lacks permissions to perform actions
- Cannot Send DM (50007): When users have disabled DMs
- Unknown Role (10011): When roles are deleted
- Safe API Calls: All Discord API calls are wrapped in error handlers
- Graceful Degradation: Bot continues operating even when some operations fail
- Automatic Cleanup: Invalid licenses and premiums are automatically removed
- Detailed Logging: All errors are logged for debugging purposes
- Process Error Handlers: Global handlers for unhandled promises and exceptions
The bot includes several utility functions for safe operations:
safeFetchMember()- Safely fetch guild memberssafeFetchGuild()- Safely fetch guildssafeSendDM()- Safely send direct messagessafeRemoveRole()- Safely remove roles from members
- Create License Keys: Use
/license-createto generate license keys with specific roles and expiration times - Distribute Keys: Share the generated keys with your users
- Redeem Keys: Users can redeem keys using
/license-redeem - Manage Licenses: Monitor and manage active licenses with various commands
Premium guilds get enhanced limits:
- Standard: 200 licenses max, 30 per command
- Premium: 1000 licenses max, 100 per command
/license-create <role> <time> [amount]- Create new license keys/license-redeem <key>- Redeem a license key/license-info <key>- Get information about a license/license-list- List all licenses in the server/license-delete <key>- Delete a specific license/license-delete-all- Delete all licenses/license-active- Show active licenses/license-stop <key>- Stop/deactivate a license/license-logs- View license activity logs
/premium-add <user> <time> <guildid>- Add premium to a user/guild/premium-delete <user> <guildid>- Remove premium/premium-edit <user> <guildid> <time>- Edit premium duration/premium-info <user> <guildid>- Get premium information/premium-list- List all premium users
/help- Show help information/ping- Check bot latency
The bot uses PostgreSQL with the following main tables:
- License: Stores license keys, roles, expiration dates, and redemption status
- Premium: Manages premium memberships for users and guilds
- Logs: Tracks license-related activities
pnpm start- Build and start the botpnpm run build- Compile TypeScriptpnpm run watch- Watch for changes and recompilepnpm run clean- Clean build directory
src/
βββ commands/ # Slash commands
β βββ general/ # General utility commands
β βββ license/ # License management commands
β βββ premium/ # Premium system commands
β βββ context/ # Context menu commands
βββ events/ # Discord.js event handlers
βββ structures/ # Base classes and utilities
βββ languages/ # Internationalization files
βββ misc/ # Utility functions
βββ types/ # TypeScript type definitions
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue if your problem isn't already reported
- Provide detailed information about your setup and the error
Mathis (frost.wrld)
- GitHub: @mathisdev7
- Discord: frost.wrld
- Portfolio: mathisdev.pro
This project is licensed under the MIT License - see the LICENSE file for details.
β If you find this project helpful, please consider giving it a star on GitHub!