This bot generates and verifies license keys within a Discord channel. Administrators can generate license keys using the !genkey
command, and users or applications can verify keys using the !verifykey <key>
command.
- Generates 16-character alphanumeric license keys
- Verifies license keys
- Offers to generate a license key for a user if the key is invalid
-
Clone the repository.
-
Install dependencies:
pip install discord.py python-dotenv
-
Create a
.env
file and add your Discord bot token:DISCORD_TOKEN=your_discord_bot_token
-
Run the bot:
python bot.py
!genkey
: Generates a new license key (Admin only).!verifykey <key>
: Verifies if a given key is valid.
To integrate this with your application:
-
Upon launch, the application asks for a license key.
-
The application sends a message to a specific Discord channel (through the bot or an API) with the key:
!verifykey YOUR_LICENSE_KEY
-
If the key is valid, the application proceeds. If not, the bot will ask:
- "Would you like to generate a key for this user?"
- Admins can choose to create or deny the request.
Example in your app:
import requests
def verify_license_in_discord(key):
# This function sends a message to the Discord bot to verify the license
discord_webhook_url = 'YOUR_DISCORD_WEBHOOK_URL'
message = f'!verifykey {key}'
data = {"content": message}
response = requests.post(discord_webhook_url, json=data)
if response.status_code == 204: # Webhook executed successfully
print("License verification request sent.")
else:
print("Failed to send license verification request.")
def launch_application():
license_key = input("Enter your license key: ")
verify_license_in_discord(license_key)
launch_application()
- Python 3.6 or higher
- discord.py
- python-dotenv