goat
command
slot
Play Slot Machine Game & Win Bank Money
0
views
0
likes
0
installs
Aliases: slots, stlogame, be11t
raw source
const mongoose = require("mongoose");
const { createCanvas, loadImage } = require("canvas");
const fs = require("fs-extra");
const path = require("path");
const bankUserSchema = new mongoose.Schema({
userID: { type: String, required: true, unique: true },
balance: { type: Number, default: 0 }
});
const BankUser = mongoose.models.DiabloBankUser || mongoose.model("DiabloBankUser", bankUserSchema);
// Slot Machine Symbols
const symbols = ["๐ฐ", "๐", "7๏ธโฃ", "๐", "๐", "๐", "๐"];
// Maximum Bet Limit: 69 Billion
const MAX_BET = 69000000000;
module.exports = {
config: {
name: "slot",
aliases: ["slots", "stlogame", "be11t"],
version: "1.2.0",
author: "Protik Shah",
countDown: 5,
role: 0,
shortDescription: "Play Slot Machine Game & Win Bank Money",
category: "games",
guide: { en: "{p}slot <bet_amount / 1k / 1m / 1b / max>" }
},
formatMoney: function (num) {
if (num >= 1000000000) return (num / 1000000000).toFixed(1).replace(/\.0$/, "") + "B";
if (num >= 1000000) return (num / 1000000).toFixed(1).replace(/\.0$/, "") + "M";
if (num >= 1000) return (num / 1000).toFixed(1).replace(/\.0$/, "") + "K";
return num.toLocaleString();
},
parseBetAmount: function (input, userBalance) {
if (!input) return null;
const str = input.toString().trim().toLowerCase();
if (str === "all" || str === "max") {
return userBalance;
}
const match = str.match(/^(\d+(?:\.\d+)?)\s*([kmb])?$/);
if (!match) return null;
let value = parseFloat(match[1]);
const unit = match[2];
if (unit === "k") value *= 1000;
else if (unit === "m") value *= 1000000;
else if (unit === "b") value *= 1000000000;
return Math.floor(value);
},
onStart: async function ({ api, event, args, message, usersData }) {
const sendMsg = (txt) => message && typeof message.reply === "function" ? message.reply(txt) : api.sendMessage(txt, event.threadID, event.messageID);
const { senderID } = event;
const rawInput = args[0];
if (!rawInput) {
return sendMsg("โ ๏ธ ๐ฃ๐๐๐๐ฆ๐ ๐๐ก๐ง๐๐ฅ ๐ ๐ฉ๐๐๐๐ ๐๐๐ง ๐๐ ๐ข๐จ๐ก๐ง!\n๐ ๐๐
๐ฎ๐บ๐ฝ๐น๐ฒ: !๐๐น๐ผ๐ ๐ฑ๐ฌ๐ฌ, !๐๐น๐ผ๐ ๐ญ๐ธ, !๐๐น๐ผ๐ ๐ฑ๐บ, !๐๐น๐ผ๐ ๐ญ๐ฏ, !๐๐น๐ผ๐ ๐บ๐ฎ๐
");
}
try {
let user = await BankUser.findOne({ userID: senderID });
const currentBalance = user ? user.balance : 0;
const betAmount = this.parseBetAmount(rawInput, currentBalance);
if (betAmount === null || isNaN(betAmount) || betAmount <= 0) {
return sendMsg("โ ๏ธ ๐๐ก๐ฉ๐๐๐๐ ๐๐๐ง ๐๐ข๐ฅ๐ ๐๐ง!\n๐ ๐จ๐๐ฒ ๐ป๐๐บ๐ฏ๐ฒ๐ฟ๐ ๐ผ๐ฟ ๐๐๐ณ๐ณ๐ถ๐
๐ฒ๐ ๐น๐ถ๐ธ๐ฒ: ๐ญ๐ธ, ๐ฎ.๐ฑ๐บ, ๐ญ๐ฏ, ๐บ๐ฎ๐
");
}
// Check Max Bet Limit (69 Billion)
if (betAmount > MAX_BET) {
return sendMsg(`โ ๏ธ ๐ ๐๐ซ๐๐ ๐จ๐ ๐๐๐ง ๐๐๐ ๐๐ง ๐๐ฆ $${this.formatMoney(MAX_BET)} USD!`);
}
if (!user || currentBalance < betAmount) {
return sendMsg(`โ ๐๐ก๐ฆ๐จ๐๐๐๐๐๐๐ก๐ง ๐๐๐๐๐ก๐๐!\n๐ณ ๐ฌ๐ผ๐๐ฟ ๐๐๐ฟ๐ฟ๐ฒ๐ป๐ ๐๐ฎ๐น๐ฎ๐ป๐ฐ๐ฒ: $${this.formatMoney(currentBalance)} USD`);
}
let userName = senderID;
if (usersData && typeof usersData.getName === "function") {
try { userName = await usersData.getName(senderID); } catch (e) {}
}
// Spin Logic (3 Random Symbols)
const slot1 = symbols[Math.floor(Math.random() * symbols.length)];
const slot2 = symbols[Math.floor(Math.random() * symbols.length)];
const slot3 = symbols[Math.floor(Math.random() * symbols.length)];
let winMultiplier = 0;
let isWin = false;
if (slot1 === slot2 && slot2 === slot3) {
winMultiplier = 5; // All 3 match = 5x payout
isWin = true;
} else if (slot1 === slot2 || slot2 === slot3 || slot1 === slot3) {
winMultiplier = 2; // 2 match = 2x payout
isWin = true;
}
const winAmount = isWin ? betAmount * winMultiplier : 0;
const netChange = isWin ? winAmount - betAmount : -betAmount;
// Update Database Balance
user.balance += netChange;
await user.save();
// Canvas Rendering (Cyber Neon Slot Machine Card)
const canvas = createCanvas(900, 500);
const ctx = canvas.getContext("2d");
// Dark Background
ctx.fillStyle = "#050a14";
ctx.fillRect(0, 0, 900, 500);
// Multi-layer Laser Glow Outer Border
const laserGlows = [
{ color: isWin ? "rgba(74, 222, 128, 0.2)" : "rgba(239, 68, 68, 0.2)", blur: 35, width: 14 },
{ color: isWin ? "#4ade80" : "#ef4444", blur: 15, width: 4 },
{ color: "#ffffff", blur: 4, width: 2 }
];
laserGlows.forEach(g => {
ctx.save();
ctx.shadowColor = g.color;
ctx.shadowBlur = g.blur;
ctx.strokeStyle = g.color;
ctx.lineWidth = g.width;
ctx.strokeRect(20, 20, 860, 460);
ctx.restore();
});
// Header Banner
ctx.fillStyle = "#ffffff";
ctx.font = "900 32px 'Segoe UI', Sans-serif";
ctx.fillText("๐ฐ CASINO SLOT MACHINE ๐ฐ", 50, 75);
ctx.fillStyle = isWin ? "#4ade80" : "#ef4444";
ctx.font = "bold 15px 'Segoe UI', Sans-serif";
ctx.fillText(isWin ? `โบ BIG WIN! YOU WON ${winMultiplier}X MULTIPLIER` : "โบ BETTER LUCK NEXT TIME!", 52, 102);
// User Avatar Render
try {
const avatarUrl = `https://graph.facebook.com/${senderID}/picture?height=300&width=300&access_token=6628568379%7Cc1e620fa708a1d5696fb991c1bde5662`;
const avatarImg = await loadImage(avatarUrl);
ctx.save();
ctx.shadowColor = isWin ? "#4ade80" : "#ef4444";
ctx.shadowBlur = 20;
ctx.beginPath();
ctx.arc(740, 115, 60, 0, Math.PI * 2);
ctx.clip();
ctx.drawImage(avatarImg, 680, 55, 120, 120);
ctx.restore();
ctx.strokeStyle = isWin ? "#4ade80" : "#ef4444";
ctx.lineWidth = 4;
ctx.beginPath(); ctx.arc(740, 115, 60, 0, Math.PI * 2); ctx.stroke();
} catch (e) {}
// 3 Slot Reel Boxes
const reels = [slot1, slot2, slot3];
const startX = 140;
for (let i = 0; i < 3; i++) {
const boxX = startX + (i * 210);
const boxY = 150;
// Reel Box Background
ctx.fillStyle = "rgba(15, 23, 42, 0.8)";
ctx.beginPath();
ctx.roundRect(boxX, boxY, 180, 180, 16);
ctx.fill();
ctx.strokeStyle = isWin ? "#4ade80" : "rgba(255, 255, 255, 0.15)";
ctx.lineWidth = 3;
ctx.stroke();
// Symbol Render
ctx.fillStyle = "#ffffff";
ctx.font = "80px 'Segoe UI Emoji', 'Segoe UI', Sans-serif";
ctx.textAlign = "center";
ctx.fillText(reels[i], boxX + 90, boxY + 118);
ctx.textAlign = "left";
}
// Footer Stats Dashboard
ctx.fillStyle = "#64748b";
ctx.font = "bold 14px 'Segoe UI', Sans-serif";
ctx.fillText("PLAYER", 50, 385);
ctx.fillText("BET AMOUNT", 300, 385);
ctx.fillText(isWin ? "PROFIT" : "LOSS", 520, 385);
ctx.fillText("NEW BALANCE", 700, 385);
ctx.fillStyle = "#ffffff";
ctx.font = "bold 20px 'Segoe UI', Sans-serif";
const shortName = userName.length > 15 ? userName.substring(0, 15) + "..." : userName;
ctx.fillText(shortName, 50, 415);
ctx.fillStyle = "#38bdf8";
ctx.fillText(`$${this.formatMoney(betAmount)}`, 300, 415);
ctx.fillStyle = isWin ? "#4ade80" : "#ef4444";
ctx.fillText(`${isWin ? "+" : "-"}$${this.formatMoney(Math.abs(isWin ? winAmount : betAmount))}`, 520, 415);
ctx.fillStyle = "#f1c40f";
ctx.fillText(`$${this.formatMoney(user.balance)}`, 700, 415);
// Save and Send Attachment
const cacheDir = path.join(__dirname, "cache");
await fs.ensureDir(cacheDir);
const cachePath = path.join(cacheDir, `slot_${senderID}_${Date.now()}.png`);
await fs.writeFile(cachePath, canvas.toBuffer("image/png"));
const payload = {
body: isWin
? `๐ ๐๐ข๐ก๐๐ฅ๐๐ง๐จ๐๐๐ง๐๐ข๐ก๐ฆ ${userName.toUpperCase()}!\n๐ ๐ฌ๐ข๐จ ๐ช๐ข๐ก $${this.formatMoney(winAmount)} USD!`
: `๐ ๐๐๐ง๐ง๐๐ฅ ๐๐จ๐๐ ๐ก๐๐ซ๐ง ๐ง๐๐ ๐ ${userName.toUpperCase()}!\n๐ ๐ฌ๐ข๐จ ๐๐ข๐ฆ๐ง $${this.formatMoney(betAmount)} USD!`,
attachment: fs.createReadStream(cachePath)
};
const sendCallback = () => { if (fs.existsSync(cachePath)) fs.unlinkSync(cachePath); };
return message && typeof message.reply === "function" ? message.reply(payload, sendCallback) : api.sendMessage(payload, event.threadID, sendCallback, event.messageID);
} catch (err) {
console.error(err);
return sendMsg("โ ๐ฆ๐๐ข๐ง ๐๐๐ ๐ ๐๐ฅ๐ฅ๐ข๐ฅ!");
}
}
};