A Discord bot demonstration showcasing DRIP's points management API capabilities.
This demo showcases the integration between Discord and DRIP's points management API. It demonstrates how easily developers can integrate DRIP's token system into their Discord applications, providing basic economy features through simple slash commands.
- Balance Checking: Query DRIP point balances directly through Discord
- Tipping System: Enable user-to-user DRIP point transfers
- Administrative Controls: Server management of DRIP points
- DRIP API Integration: Seamless connection with DRIP's token system
- Error Handling: Robust error checking and user feedback
- Resource Management: Efficient API session handling
- Python 3.8 or higher
- Discord bot token
- DRIP API credentials
Create a .env
file with:
TOKEN=your_discord_bot_token
API_BASE_URL=https://api.drip.re
API_KEY=your_drip_api_key
REALM_ID=your_drip_realm_id
Discord token is the token of the bot, you can get one by creating an app and then generating a token. GUIDE
DRIP API key and realm ID can be found in your DRIP Admin channel in the server you want to use.
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
- Configure environment variables
- Run the bot:
python bot.py
-
Check DRIP Balance
/balance
- Shows your current DRIP point balance
- Response is private
-
Check Other's Balance
/check <user>
- Shows another user's DRIP balance
-
Tip DRIP Points
/tip <user> <amount>
- Transfer DRIP points to another user
- Requires sufficient balance
- Amount must be positive
-
Add DRIP Points
/add_points <user> <amount>
- Adds DRIP points to a user
- Requires administrator permissions
-
Remove DRIP Points
/remove_points <user> <amount>
- Removes DRIP points from a user
- Requires administrator permissions
The demo utilizes the following DRIP API endpoints:
-
Balance Check
GET /api/v4/realms/{realm_id}/members/{user_id}
Returns user's DRIP point balance
-
Point Modification
PATCH /api/v4/realms/{realm_id}/members/{user_id}/tokenBalance
Modifies user's DRIP point balance
-
Point Transfer
PATCH /api/v4/realms/{realm_id}/members/{user_id}/transfer
Handles user-to-user DRIP point transfers
Uses DRIP's API key authentication:
headers = {"Authorization": f"Bearer {api_key}"}
Implements a singleton pattern for managing DRIP API connections:
class PointsManagerSingleton:
"""
Manages DRIP API connections and point operations.
Ensures efficient resource usage through singleton pattern.
"""
- Secure API key handling
- Efficient session management
- Comprehensive error handling
- User-friendly responses
- Permission-based access control
/balance
> Your DRIP balance: 1,000 Points
/tip @user 100
> Successfully tipped 100 DRIP Points to @user!
/add_points @user 500
> Successfully added 500 DRIP Points to @user!
> Their new balance: 1,500 Points
/remove_points @user 200
> Successfully removed 200 DRIP Points from @user!
> Their new balance: 1,300 Points