455 commands2 envUpdated 6h agoCreated Aug 26, 2026
commands/sdel.js
javascript · 59 lines
1/**#command2name: sdel3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12/**#command13name: sdel14answer: 15keyboard: 16parse_mode: markdown17aliases: 18allow_only_group: false19need_reply: false20is_web: 021#command**/22 23try {24try { Api.answerCallbackQuery({}); } catch (e0) {}25var uid = "";26if (typeof user !== "undefined" && user) {27 if (user.telegramid) uid = String(user.telegramid);28 else if (user.id) uid = String(user.id);29}30var isBoss = (uid === "5861439682");31var isAdmin = isBoss || ((await db.global.get("rank_" + uid)) === "admin");32if (!isAdmin) { Bot.sendMessage("🚫 فقط ادمین"); return; }33var num = 0;34if (typeof params !== "undefined" && params) num = parseInt(String(params).replace(/[^0-9]/g, "")) || 0;35if (num < 1) { Bot.sendMessage("حذف:\n/sdel شماره"); return; }36var products = [];37try { products = JSON.parse(String((await db.global.get("shop_products")) || "[]")); } catch (eP) { products = []; }38if (!products || typeof products.length !== "number") products = [];39var nxt = [];40var i = 0;41var hit = false;42var oldt = "";43for (i = 0; i < products.length; i++) {44 if (!products[i]) continue;45 var n = parseInt(products[i].num);46 if (!n) n = i + 1;47 if (n === num || parseInt(products[i].id) === num) {48 hit = true;49 oldt = String(products[i].title || "");50 continue;51 }52 nxt.push(products[i]);53}54if (!hit) { Bot.sendMessage("شماره محصول نیست."); return; }55await db.global.set("shop_products", JSON.stringify(nxt));56Bot.sendMessage("🗑 حذف شد: " + oldt);57} catch (e) {58 Bot.sendMessage("خطا sdel");59}