Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Official and maintained Licensy discord bot. Manage license keys and premium roles with ease.

License

mathisdev7/licensy

Repository files navigation

Licensy πŸ”‘

A powerful Discord bot for managing license keys and premium memberships within your Discord server.

Developer Note

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! πŸ’™

πŸ“‹ Table of Contents

✨ Features

  • 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

πŸ”§ Prerequisites

πŸš€ Installation

  1. Clone the repository

    git clone https://github.com/mathisdev7/licensy.git
    cd licensy
  2. Install dependencies

    pnpm install
  3. Set up environment variables

    cp .env.example .env

    Edit the .env file 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
  4. Set up the database

    pnpm prisma migrate deploy
    pnpm prisma generate
  5. Start the bot

    pnpm start

βš™οΈ Configuration

Environment Variables

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) βœ…

Bot Permissions

Make sure your bot has the following permissions:

  • Send Messages
  • Use Slash Commands
  • Manage Roles
  • Read Message History
  • Embed Links

Error Handling & Anti-Crash System

Licensy v3 includes a robust error handling system to prevent crashes from common Discord API errors:

Common Errors Handled

  • 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

Safety Features

  • 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

Utility Functions

The bot includes several utility functions for safe operations:

  • safeFetchMember() - Safely fetch guild members
  • safeFetchGuild() - Safely fetch guilds
  • safeSendDM() - Safely send direct messages
  • safeRemoveRole() - Safely remove roles from members

Usage

Basic Workflow

  1. Create License Keys: Use /license-create to generate license keys with specific roles and expiration times
  2. Distribute Keys: Share the generated keys with your users
  3. Redeem Keys: Users can redeem keys using /license-redeem
  4. Manage Licenses: Monitor and manage active licenses with various commands

Premium Features

Premium guilds get enhanced limits:

  • Standard: 200 licenses max, 30 per command
  • Premium: 1000 licenses max, 100 per command

🎯 Commands

License Commands

  • /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 Commands

  • /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

General Commands

  • /help - Show help information
  • /ping - Check bot latency

πŸ—„οΈ Database Schema

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

πŸ› οΈ Development

Scripts

  • pnpm start - Build and start the bot
  • pnpm run build - Compile TypeScript
  • pnpm run watch - Watch for changes and recompile
  • pnpm run clean - Clean build directory

Project Structure

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

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ†˜ Support

If you encounter any issues or have questions:

  1. Check the Issues page
  2. Create a new issue if your problem isn't already reported
  3. Provide detailed information about your setup and the error

πŸ‘¨β€πŸ’» Author

Mathis (frost.wrld)

πŸ“„ License

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!

About

Official and maintained Licensy discord bot. Manage license keys and premium roles with ease.

Resources

License

Stars

Watchers

Forks

Packages

No packages published