Created At: 2026-11-18T04:44:00Z Completed At: 2026-11-18T04:44:00Z Command exited with code 0. Command output: const { Markup } = require('telegraf'); const { CREDIT_EMOJI } = require('../core/fonts'); async function sendMySubscriptionDetails(ctx, { pool, checkUserAccess, formatIST }) { const userId = ctx.from.id; const access = await checkUserAccess(userId); let subRecord = null; if (pool) { try { const subRes = await pool.query( `SELECT * FROM user_subscriptions WHERE telegram_id = $1 ORDER BY id DESC LIMIT 1`, [userId] ); if (subRes.rows.length > 0) { subRecord = subRes.rows[0]; } } catch (e) { console.error("Error fetching user_subscriptions:", e.message); } } let statusText = ''; let planText = ''; let durationText = ''; let purchaseDateText = ''; let expiryDateText = ''; let paymentMethodText = ''; let amountPaidText = ''; let searchAccessText = ''; let buttons = []; if (access.isAdmin) { statusText = 'Active (VIP Master Pass)'; planText = 'UNLIMITED VIP'; durationText = 'Lifetime (No Expiry)'; purchaseDateText = formatIST(access.planStartedAt) || 'Account Activation'; expiryDateText = 'Lifetime Access (Never Expires)'; paymentMethodText = '👑 Admin Master Access'; amountPaidText = '₹0 (Master Key)'; searchAccessText = 'Unlimited Searches (Zero Deduction)'; buttons = [ [{ text: '🛒 View Store', callback_data: 'BUY_CREDITS_MENU', style: 'primary' }] ]; } else if (access.isUnlimited) { statusText = 'Active 🟢'; planText = 'UNLIMITED VIP'; durationText = access.subscriptionDuration || subRecord?.duration || 'Unlimited'; purchaseDateText = formatIST(access.planStartedAt || subRecord?.started_at) || 'Active'; expiryDateText = formatIST(access.planExpiresAt || subRecord?.expires_at) || 'Active'; paymentMethodText = access.subscriptionPaymentMethod || subRecord?.payment_method || 'UPI (QR Code)'; amountPaidText = access.subscriptionAmount || subRecord?.amount || 'Paid'; searchAccessText = 'Unlimited Searches (Zero Deduction)'; buttons = [ [{ text: '🛒 Extend / Buy Plan', callback_data: 'BUY_UNLIMITED_PLANS', style: 'primary' }] ]; } else if (subRecord || (access.planExpiresAt && access.planExpiresAt <= new Date())) { statusText = 'Expired 🔴'; planText = subRecord?.plan_name || 'UNLIMITED VIP'; durationText = access.subscriptionDuration || subRecord?.duration || 'Expired'; purchaseDateText = formatIST(access.planStartedAt || subRecord?.started_at) || 'N/A'; expiryDateText = formatIST(access.planExpiresAt || subRecord?.expires_at) || 'Expired'; paymentMethodText = access.subscriptionPaymentMethod || subRecord?.payment_method || 'UPI (QR Code)'; amountPaidText = access.subscriptionAmount || subRecord?.amount || 'Paid'; searchAccessText = `${access.credits} Credits Available (Pay Per Search)`; buttons = [ [{ text: '💎 Renew VIP Plan', callback_data: 'BUY_UNLIMITED_PLANS', style: 'primary' }], [{ text: '🪙 Buy Credits', callback_data: 'BUY_CUSTOM_CREDITS', style: 'primary' }] ]; } else { statusText = 'No Active Subscription ⚪'; planText = 'Free Tier (Pay Per Search)'; durationText = 'N/A'; purchaseDateText = 'N/A (No subscription purchased yet)'; expiryDateText = 'N/A'; paymentMethodText = 'N/A'; amountPaidText = 'N/A'; const freeBadge = access.hasFreeSearch ? 'Available (1/1)' : 'Used Today (Resets 12:00 AM IST)'; searchAccessText = `Daily Free: ${freeBadge} | Wallet: ${access.credits} Credits`; buttons = [ [{ text: '💎 Buy Unlimited VIP Plan', callback_data: 'BUY_UNLIMITED_PLANS', style: 'primary' }], [{ text: '🪙 Buy Credits', callback_data: 'BUY_CUSTOM_CREDITS', style: 'primary' }] ]; } const subMsg = `USER SUBSCRIPTION DETAILS\n` + `━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + `Name: ${ctx.from.first_name || 'User'}\n` + `━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + `User ID: ${userId}\n` + `━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + `Status: ${statusText}\n` + `━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + `Plan: ${planText}\n` + `━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + `Kitne Din Ka (Duration): ${durationText}\n` + `━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + `Kab Kharida (Purchase Date): ${purchaseDateText}\n` + `━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + `Expiry Date: ${expiryDateText}\n` + `━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + `Payment Method: ${paymentMethodText}\n` + `━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + `Amount Paid: ${amountPaidText}\n` + `━━━━━━━━━━━━━━━━━━━━━━━━━━\n` + `Search Access: ${searchAccessText}`; return ctx.reply(subMsg, { parse_mode: 'HTML', ...Markup.inlineKeyboard(buttons) }); } function registerMySubscriptionCommand(bot, deps) { bot.command(['mysubscription', 'subscription', 'plan', 'myplan'], async (ctx) => { await sendMySubscriptionDetails(ctx, deps); }); bot.action('VIEW_MY_SUBSCRIPTION', async (ctx) => { ctx.answerCbQuery().catch(() => {}); await sendMySubscriptionDetails(ctx, deps); }); } module.exports = { registerMySubscriptionCommand, sendMySubscriptionDetails };