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/_removeplan.js

javascript · 90 lines

Raw
1/**#command2name: /removeplan3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12try {13  // Apni Admin Telegram ID yahan dalein14  var adminId = "8963001413";15 16  if (String(chat.chatid) !== adminId) {17    Bot.sendMessage("❌ You are not the admin!");18    return;19  }20 21  // Format validation verification22  if (!params) {23    Bot.sendMessage("⚠️ Format: `/removeplan PRODUCT NAME | DAYS`\n\n*Example:* `/removeplan FreeFire Hack | 1`", { parse_mode: "Markdown" });24    return;25  }26 27  var data = params.split("|");28  if (data.length < 2) {29    Bot.sendMessage("⚠️ Galat Format! Product Name aur Days '|' se alag honi chahiye.");30    return;31  }32 33  var pName = data[0].trim().toLowerCase();34  var pDays = data[1].trim();35 36  // Database se existing products list nikalna37  var productList = Bot.getProperty("stored_products") || [];38  var productIndex = -1;39 40  // 1. Pehle product find karein41  for (var i = 0; i < productList.length; i++) {42    if (productList[i].name.toLowerCase() === pName) {43      productIndex = i;44      break;45    }46  }47 48  if (productIndex === -1) {49    Bot.sendMessage("❌ Product **" + data[0].trim() + "** database me nahi mila!", { parse_mode: "Markdown" });50    return;51  }52 53  var product = productList[productIndex];54  var plans = product.plans || [];55  var planIndex = -1;56 57  // 2. Us product ke andar targeted plan find karein58  for (var j = 0; j < plans.length; j++) {59    if (String(plans[j].days) === pDays) {60      planIndex = j;61      break;62    }63  }64 65  if (planIndex === -1) {66    Bot.sendMessage("❌ Product me **" + pDays + " Days** wala koi plan nahi mila!", { parse_mode: "Markdown" });67    return;68  }69 70  // 3. Plan ko array se remove (delete) karna71  plans.splice(planIndex, 1);72 73  var feedbackMsg = "";74  75  // 4. Verification Check: Agar saare plans delete ho chuke hain, toh product hi remove kar do76  if (plans.length === 0) {77    productList.splice(productIndex, 1);78    feedbackMsg = "🗑️ Product **" + product.name + "** ka aakhri plan thha, isliye poora product list se remove ho gaya!";79  } else {80    productList[productIndex].plans = plans;81    feedbackMsg = "✅ Product **" + product.name + "** se **" + pDays + " Days** wala plan successfully remove ho gaya!";82  }83 84  // 5. Updated list database me save karna85  Bot.setProperty("stored_products", productList, "json");86  Bot.sendMessage(feedbackMsg, { parse_mode: "Markdown" });87 88} catch (err) {89  Bot.sendMessage("⚠️ Error: " + err.message);90}