๐
pasted-code-1772544946623.txt
txt
272 lines
โถ
You are a senior backend + Discord bot developer with 5+ years of production experience.
Build a production-ready Discord earning bot using:
* Discord.js v14
* Node.js
* Express.js (for API)
* MongoDB (or PostgreSQL if structured)
* Secure token-based API system
* Environment variables for secrets
This bot is a professional earning ecosystem where users complete shortlinks and tasks to earn credits.
The bot must be scalable, secure, and modular.
---
## CORE FEATURES
1. ECONOMY SYSTEM
Currency name must be configurable in config file.
User fields:
* user_id
* balance
* total_earned
* total_withdrawn
* shortlinks_completed
* tasks_completed
* withdraw_count
* referral_count
* referrer_id
* daily_last_claim
* daily_streak
* risk_score
* is_blacklisted
* created_at
---
2. USER COMMANDS
Use Slash Commands.
โข /balance (aliases: /bal, /wallet)
Shows:
* Balance
* Total Earned
* Withdrawn
* Shortlinks completed
* Tasks completed
* Referrals
โข /daily
* 24 hour cooldown
* Configurable default daily reward
* Optional streak bonus
* Prevent claim if account age less than configured days
โข /tasks
Shows interactive buttons:
* Shortlinks
* Offer tasks
* Manual tasks
Each task must:
* Generate unique tracking token
* Store pending session
* Prevent duplicate completion
* Respect cooldown
* Respect daily limit
โข /referral
Shows:
* Personal referral link
* Referral count
* Lifetime commission percentage
Referral system:
* Configurable commission %
* Lifetime commission
* Prevent self-referral
* Detect suspicious mass referrals
โข /withdraw
Flow:
1. Ask amount
2. Validate minimum withdraw
3. Validate balance
4. Ask method (UPI / Paytm / Crypto / Giftcard)
5. Create withdraw request
6. Deduct or freeze balance
---
3. ADMIN COMMANDS
Admin-only role configurable.
Economy control:
* /admin addcredits @user amount
* /admin removecredits @user amount
* /admin setcredits @user amount
* /admin resetuser @user
User tracking:
* /admin userstats @user
* /admin topwithdraws
* /admin toptasks
* /admin suspicious
Task management:
* /admin task create shortlink
* /admin task create joinserver
* /admin task create manual
* /admin task disable
* /admin task delete
Limits:
* /admin setlimit shortlink daily amount
* /admin setlimit shortlink cooldown minutes
* /admin setlimit task daily amount
* /admin setearningcap amount
* /admin setdaily amount
* /admin setwithdrawlimit amount
* /admin setwithdrawcooldown hours
* /admin setaccountage days
* /admin setvpnblock true/false
Security:
* /admin blacklist @user
* /admin unblacklist @user
* /admin freezeuser @user
---
4. AUTO CREDIT API SYSTEM
Build Express backend with:
POST /api/complete
Body:
{
user_id,
task_id,
token,
signature
}
Logic:
* Validate token exists
* Validate not already credited
* Validate signature secret
* Add reward
* Add referral commission
* Update stats
* Send log to Discord log channel
* Return JSON success response
Must include:
* Rate limit
* IP logging
* Replay protection
* Token expiration
---
5. ANTI ABUSE SYSTEM
Implement:
* IP hash logging
* Device fingerprint support
* Daily earning cap
* Daily shortlink limit
* Daily task limit
* Account age requirement
* VPN detection toggle
* Suspicious risk scoring system
---
6. CONFIG SYSTEM
config.json must contain:
* currency_name
* daily_reward_default
* referral_percentage
* withdraw_minimum
* shortlink_default_reward
* shortlink_daily_limit
* task_daily_limit
* earning_cap_daily
* admin_role_id
* log_channel_id
* api_secret_key
---
7. LOGGING SYSTEM
Create separate Discord log channel for:
* Task completed
* Credits added
* Withdraw request
* Referral bonus
* Admin actions
* Suspicious detection
---
8. PROJECT STRUCTURE
Follow clean architecture:
/commands
/events
/models
/routes
/services
/utils
/config
/index.js
Use async/await properly.
Use error handling middleware.
Use environment variables for sensitive data.
---
9. IMPORTANT RULES
* No hardcoded secrets
* No duplicate credit possible
* No negative balance allowed
* Fully modular code
* Production-ready structure
* Include comments
* Use secure validation
---
At the end:
Provide full project file structure and explanation.
This is a real earning bot intended for large-scale use (5,000+ users).
Make it optimized and secure.
---
END OF INSTRUCTIONS.
Iโll create a production-ready Discord earning bot with complete anti-abuse protection, API system, and modular architecture.
โ Complete Production-Ready Discord Earning Bot Created
Files Created: 41 files
๐ฏ Core Features Implemented:
Economy System - Full user tracking with balance, earnings, withdrawals, referrals
User Commands -
/balance,/daily,/tasks,/referral,/withdrawAdmin Commands - 15+ admin commands for complete control
API System - Express backend with signature verification and rate limiting
Anti-Abuse - Risk scoring, IP logging, earning caps, daily limits
Referral System - Lifetime commissions with abuse prevention
Task Management - Create, disable, delete tasks with cooldowns
Logging System - Complete Discord channel logging for all activities
Security - Blacklisting, freezing, VPN detection, account age requirements
๐ Project Structure:
Modular architecture with separate services, commands, models
MongoDB with Mongoose for scalability
Express API with helmet and rate limiting
Discord.js v14 with slash commands
Complete error handling and validation
๐ Setup Instructions:
Run
npm installCopy
.env.exampleto.envand add your credentialsUpdate
config.jsonwith your Discord role/channel IDsRun
npm start
The bot is production-ready for 5,000+ users with comprehensive security, scalability, and professional error handling.
add help command for user and admin both and add admin user only can use the admin commands.
const connectDatabase = require('./config/database');
const { startBot } = require('./bot');
const { startServer } = require('./server');
async function main() {
console.log('๐ Starting Discord Earning Bot...\n');
await connectDatabase();
startServer();
await startBot();
console.log('\nโ
All systems operational!');
}
main().catch(error => {
console.error('โ Fatal error:', error);
process.exit(1);
});
process.on('unhandledRejection', (error) => {
console.error('โ Unhandled promise rejection:', error);
});
process.on('uncaughtException', (error) => {
console.error('โ Uncaught exception:', error);
process.exit(1);
});