A Discord bot for automated license verification of Payhip digital products.
Invite to your server — Project page
KeyVerify lets Payhip sellers gate Discord roles behind license key verification. When a user verifies, the bot checks the key against the Payhip API and assigns the configured role. The verification result is recorded so roles can be automatically reapplied if a verified user rejoins. License keys are never stored.
- In-server verification via modal — no DMs or external links required
- Automatic role assignment and reassignment on rejoin
- Per-product configuration with optional auto-created roles
- License reset support for reactivations
- AES encryption (Fernet) for stored product secrets
- License keys are never stored — only the fact that verification occurred
- Key rotation: swap encryption keys without data loss
- Verification logging per server
- Rate limiting to prevent abuse
- Persistent verification buttons — survive bot restarts
| Command | Description |
|---|---|
/start_verification |
Post the verification button to a channel. |
/add_product |
Register a product with its Payhip secret and an optional role. |
/edit_product |
Rename a product or change its assigned role. |
/remove_product |
Remove a product from the server. |
/list_products |
List all registered products and their roles. |
/reset_key |
Reset the usage count of a license key on Payhip. |
/set_lchannel |
Set the channel where verification events are logged. |
/remove_user |
Revoke a user's access and remove their verification records. License disabling on Payhip must be done manually from your Payhip dashboard. |
/help |
Show available commands and support information. |
All commands require server administrator permissions.
1. Clone the repository
git clone https://github.com/Fayelicious/KeyVerify.git
cd KeyVerify
2. Install dependencies
pip install -r requirements.txt
3. Generate an encryption key
python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
Copy the output — you'll need it in the next step.
4. Create a .env file
DISCORD_TOKEN=your_discord_bot_token
PAYHIP_API_KEY=your_payhip_api_key
DATABASE_URL=your_postgres_connection_url
ENCRYPTION_KEYS=your_generated_key
LOG_LEVEL=INFO
5. Run the bot
python bot.py
The bot requires the following Discord permissions: Manage Roles, Send Messages, Read Message History.
To replace your encryption key without losing access to stored data:
- Generate a new key using the command in step 3 above.
- Prepend it to
ENCRYPTION_KEYS, separated by a comma:ENCRYPTION_KEYS=NEW_KEY,OLD_KEY - Restart the bot. On startup it will re-encrypt all records using the new key.
- Once the log confirms rotation is complete, remove the old key from
.env.
- disnake
- asyncpg
- aiohttp
- cryptography
- Python 3.11+
Discord: Fayelicious_