The following changes were made by the replace_file_content tool to: /root/aadharbot/index.js. If relevant, proactively run terminal commands to execute this code for the USER. Don't ask for permission. [diff_block_start] @@ -2034,10 +2034,13 @@ return null; } -async function assignPlanToUser(targetUserId, planDuration) { +async function assignPlanToUser(targetUserId, planDuration, paymentMethod = 'Admin Manual Activation', amount = '₹0 (Admin)') { const days = parsePlanDurationDays(planDuration); if (!days) throw new Error("Invalid plan duration. Supported: daily, weekly, monthly, yearly, or {day}day (e.g. 15day)"); const planExpiry = new Date(Date.now() + days * 24 * 60 * 60 * 1000); + const durationLabel = ['daily', 'weekly', 'monthly', 'yearly'].includes(planDuration) + ? `${days} Days (${planDuration.toUpperCase()})` + : `${days} Days`; if (!process.env.DATABASE_URL) { const fs = require('fs'); @@ -2051,18 +2051,33 @@ db[targetUserId].plan_type = 'unlimited'; db[targetUserId].plan_expires_at = planExpiry.toISOString(); db[targetUserId].plan_started_at = new Date().toISOString(); - fs.writeFileSync('db.json', JSON.stringify(db, null, 2)); - } else { - await pool.query( - `INSERT INTO users (telegram_id, name, credits, plan_type, plan_expires_at, plan_started_at, created_at, updated_at) - VALUES ($1, 'User', 0, 'unlimited', $2, NOW(), NOW(), NOW()) - ON CONFLICT (telegram_id) - DO UPDATE SET plan_type = 'unlimited', plan_expires_at = EXCLUDED.plan_expires_at, plan_started_at = NOW(), updated_at = NOW()`, - [targetUserId, planExpiry] - ); + db[targetUserId].subscription_duration = durationLabel; + db[targetUserId].subscription_payment_method = paymentMethod; + db[targetUserId].subscription_amount = amount; + fs.writeFileSync('db.json', JSON.stringify(db, null, 2)); + } else { + await pool.query( + `INSERT INTO users (telegram_id, name, credits, plan_type, plan_expires_at, plan_started_at, subscription_duration, subscription_payment_method, subscription_amount, created_at, updated_at) + VALUES ($1, 'User', 0, 'unlimited', $2, NOW(), $3, $4, $5, NOW(), NOW()) + ON CONFLICT (telegram_id) + DO UPDATE SET + plan_type = 'unlimited', + plan_expires_at = EXCLUDED.plan_expires_at, + plan_started_at = NOW(), + subscription_duration = EXCLUDED.subscription_duration, + subscription_payment_method = EXCLUDED.subscription_payment_method, + subscription_amount = EXCLUDED.subscription_amount, + updated_at = NOW()`, + [targetUserId, planExpiry, durationLabel, paymentMethod, amount] + ); + await pool.query( + `INSERT INTO user_subscriptions (telegram_id, plan_name, duration, days, amount, payment_method, started_at, expires_at, status) + VALUES ($1, $2, $3, $4, $5, $6, NOW(), $7, 'ACTIVE')`, + [targetUserId, `${planDuration.toUpperCase()} Plan`, durationLabel, days, amount, paymentMethod, planExpiry] + ).catch(() => {}); } invalidateUserCache(targetUserId); - return { planExpiry, days }; + return { planExpiry, days, durationLabel }; } [diff_block_end] Please note that the above snippet only shows the MODIFIED lines from the last change. It shows up to 3 lines of unchanged lines before and after the modified lines. The actual file contents may have many more lines not shown.