discordDiscord Bots

SunLicense Integration Guide for Discord Bots

Prerequisites

  • Node.js environment (for Discord.js)

  • Your Discord bot project

  • SunLicense API credentials

Integration Steps

1. Install Required Packages

npm install axios

2. Create License Validator

const axios = require('axios');

class LicenseValidator {
    constructor(licenseKey, productId) {
        this.licenseKey = licenseKey;
        this.productId = productId;
        this.apiUrl = 'YOUR_API_URL/api/v1/validate';
    }

    async validateLicense() {
        try {
            const response = await axios.post(this.apiUrl, {
                licenseKey: this.licenseKey,
                productId: this.productId,
                hwid: 'YOUR-HWID', // Optional
                productVersion: '1.0.0'
            });

            return response.status === 200;
        } catch (error) {
            console.error('License validation failed:', error.message);
            return false;
        }
    }
}

3. Implement in Bot

Best Practices

  1. Startup Validation

    • Validate before bot initialization

    • Implement graceful shutdown

    • Clear error logging

  2. Periodic Validation

    • Regular license checks

    • Handle network issues

    • Graceful error handling

  3. Security

    • Secure storage of license key

    • Environment variable usage

    • Proper error handling

Common Issues

  1. Validation Failures

    • Check license key validity

    • Verify network connectivity

    • Confirm product ID

  2. Runtime Issues

    • Monitor bot logs

    • Check for API rate limits

    • Verify license status

Last updated