455 commands2 envUpdated 7h agoCreated Aug 26, 2026
commands/pvpd.js
javascript · 86 lines
1/**#command2name: pvpd3answer: 4keyboard: 5parse_mode: markdown6aliases: 7allow_only_group: false8need_reply: false9is_web: 010#command**/11 12/**#command13name: pvpd14answer: 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}30if (!uid) return;31var gift = await db.global.get("wal_gift_" + uid);32if (!gift) {33 await db.global.set("wal_gift_" + uid, "1");34 var c0 = parseInt(await db.global.get("wal_" + uid) || 0) || 0;35 await db.global.set("wal_" + uid, c0 + 10000);36}37var cost = 2000;38var bal = parseInt(await db.global.get("wal_" + uid) || 0) || 0;39if (bal < cost) { Bot.sendMessage("حداقل ۲۰۰۰. کیف: " + bal); return; }40 41var wait = String((await db.global.get("pvpq_dice")) || "");42if (wait && wait === uid) {43 Bot.sendMessage("تو صف تاس هستی. /pvpx لغو.");44 return;45}46 47if (wait && wait !== uid) {48 var other = wait;49 await db.global.set("pvpq_dice", "");50 var bo = parseInt(await db.global.get("wal_" + other) || 0) || 0;51 var bm = parseInt(await db.global.get("wal_" + uid) || 0) || 0;52 if (bo < cost || bm < cost) {53 Bot.sendMessage("موجودی یکی کم بود. صف باطل.");54 return;55 }56 await db.global.set("wal_" + other, bo - cost);57 await db.global.set("wal_" + uid, bm - cost);58 var d1 = 1 + Math.floor(Math.random() * 6);59 var d2 = 1 + Math.floor(Math.random() * 6);60 var detail = "تاس حریف قبلی: " + d1 + "\nتاس تو: " + d2;61 if (d1 === d2) {62 await db.global.set("wal_" + other, bo);63 await db.global.set("wal_" + uid, bm);64 var eq = "⚔️ تاس PvP\n" + detail + "\nمساوی. پول برگشت.";65 try { Api.sendMessage({ chat_id: other, text: eq }); } catch (e1) {}66 Bot.sendMessage(eq);67 return;68 }69 var win = d1 > d2 ? other : uid;70 var lose = win === other ? uid : other;71 var nw = parseInt(await db.global.get("wal_" + win) || 0) || 0;72 await db.global.set("wal_" + win, nw + 4000);73 var msg = "⚔️ تاس PvP داخل ربات\n" + detail + "\nبرنده: " + win + " +۴۰۰۰\nبازنده: " + lose;74 try { Api.sendMessage({ chat_id: other, text: msg }); } catch (eA) {}75 try { Api.sendMessage({ chat_id: uid, text: msg }); } catch (eB) {}76 return;77}78 79await db.global.set("pvpq_dice", String(uid));80Api.sendMessage({81 text: "⚔️ رفتی تو صف تاس با پلیر.\nگروه لازم نیست. هر طرف ۲۰۰۰.",82 reply_markup: { inline_keyboard: [[{ text: "❌ لغو صف", callback_data: "pvpx" }, { text: "🎮 بازیها", callback_data: "games" }]] }83});84} catch (e) {85 Bot.sendMessage("خطا pvpd");86}