mansuriamaan803/SANJEEVFFSTORE_botPublic · Bot Template

AIThis bot is a commerce platform for selling digital products, primarily focused on FreeFire accounts and related services. It provides admin tools for managing products, categories, stock, reseller roles, and a balance system for user payments. Users can browse products, apply coupons, and check their balance through an interactive interface with premium emojis and inline keyboards.

Commercecommercestoreproductsresellerbalancecoupon
ProfileTelegram
102 commands0 envUpdated 12d agoCreated Aug 26, 2026
Back to folder

commands/_coupons.js

javascript · 64 lines

Raw
1/**#command2name: /coupons3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12// =========================================================13// 🎟 ADMIN/CO-ADMIN — View all coupons with usage stats + Pause/Resume/Delete14// =========================================================15 16try {17  var ownerId = Bot.getProperty("owner_id") || "8963001413";18  var isCoAdmin = Bot.getProperty("co_admin_" + String(chat.chatid));19  if (String(chat.chatid) !== ownerId && !isCoAdmin) {20    Bot.sendMessage("❌ Restricted command!");21    return;22  }23 24  var couponList = Bot.getProperty("coupon_list") || [];25 26  if (couponList.length === 0) {27    Bot.sendMessage("<blockquote>🎟 <b>No coupons created yet.</b>\n<i>Use /gencoupon to create one.</i></blockquote>", { parse_mode: "HTML" });28    return;29  }30 31  var text = "<blockquote>🎟 <b>ALL COUPONS</b></blockquote>\n━━━━━━━━━━━━━━━━━━━━━\n\n";32  var buttons = [];33 34  for (var i = 0; i < couponList.length; i++) {35    var code = couponList[i];36    var c = Bot.getProperty("coupon_" + code);37    if (!c) continue;38 39    var claimedCount = Array.isArray(c.claimedBy) ? c.claimedBy.length : 0;40    var statusLabel = c.isPaused ? "⏸ Paused" : "✅ Active";41    var scopeLabel = c.scope === "global" ? "🌍 Global" : "📦 " + (c.productName || "?") + " (" + (c.duration || "?") + ")";42 43    text += "🏷 <b>" + code + "</b> — " + statusLabel + "\n" +44            "💸 " + c.discountPercent + "% off | 👥 " + claimedCount + "/" + c.maxClaims + " claimed\n" +45            scopeLabel + "\n\n";46 47    buttons.push([48      { text: (c.isPaused ? "▶ Resume" : "⏸ Pause") + " " + code, callback_data: "/pause_coupon " + code, style: c.isPaused ? "success" : "primary" },49      { text: "🗑 Delete " + code, callback_data: "/delete_coupon " + code, style: "danger" }50    ]);51  }52 53  buttons.push([{ text: "Back to Admin Panel", callback_data: "/admin", style: "primary", icon_custom_emoji_id: "5893163582194978381" }]);54 55  Api.sendMessage({56    chat_id: chat.chatid,57    text: text,58    parse_mode: "HTML",59    reply_markup: JSON.stringify({ inline_keyboard: buttons })60  });61 62} catch (err) {63  Bot.sendMessage("⚠️ Error: " + err.message);64}