Skip to content

Instantly share code, notes, and snippets.

@FantoX
Created August 31, 2023 17:05
Show Gist options
  • Save FantoX/63bcf78d6da0bce7d9f18343e3143fbc to your computer and use it in GitHub Desktop.
Save FantoX/63bcf78d6da0bce7d9f18343e3143fbc to your computer and use it in GitHub Desktop.
All Economy and Gambling commands
const fs = require("fs");
const config = require("../Configurations.js");
const eco = require("discord-mongoose-economy");
const ty = eco.connect(config.mongodb);
const { userData } = require("../System/MongoDB/MongoDb_Schema.js");
let mergedCommands = [
"bank",
"capacity",
"daily",
"deposit",
"gamble",
"leaderboard",
"lb",
"rob",
"slot",
"transfer",
"wallet",
"withdraw",
];
module.exports = {
name: "economy",
alias: [...mergedCommands],
uniquecommands: [
"bank",
"capacity",
"daily",
"deposit",
"gamble",
"leaderboard",
"rob",
"slot",
"transfer",
"wallet",
"withdraw",
],
description: "All Economy / Gambling related commands",
start: async (
Atlas,
m,
{ pushName, prefix, inputCMD, doReact, text, args }
) => {
const debitCard = fs.readFileSync("./Assets/card.png");
const pushname = pushName || `${botName} User`;
const cara = "cara";
switch (inputCMD) {
case "bank":
await doReact("🏦");
user = m.sender;
balance = await eco.balance(user, cara);
var role = "brokie😭";
if (`${balance.bank}` <= 1000) {
role = "broke😭";
} else if (`${balance.bank}` <= 10000) {
role = "Poor😒";
} else if (`${balance.bank}` <= 50000) {
role = "AverageπŸ’Έ";
} else if (`${balance.bank}` <= 1000000) {
role = "RichπŸ’ΈπŸ’°";
} else if (`${balance.bank}` <= 10000000) {
role = "MillionaireπŸ€‘";
} else if (`${balance.bank}` <= 90000000) {
role = "BillionaireπŸ€‘πŸ€‘";
}
let buttonMessage = {
image: debitCard,
caption: `\n🏦 *${pushname}'s Bank*:\n\nπŸͺ™ Balance: ${balance.bank}/${balance.bankCapacity}\n\n\n*Wealth: ${role}*\n`,
};
await Atlas.sendMessage(m.from, buttonMessage, { quoted: m });
break;
case "capacity":
if (!text) {
return Atlas.sendMessage(
m.from,
{
text: `γ€Ž *Bank πŸ’΄ Capacity* 』\n\n1 | *1000 sp* = 100 πŸ’Ž\n\n2 | *100000 sp* = 1000 πŸ’Ž\n\n3 | *10000000 sp* = 10000000 πŸ’Ž\n\nExample: *${prefix}capacity 1* OR *${prefix}bankupgrade 1000*`,
},
{ quoted: m }
);
}
user = m.sender;
value = text.trim();
k = parseInt(value);
balance = await eco.balance(user, cara);
switch (value) {
case "1000":
case "1":
if (k > balance.wallet)
return m.reply(
"*You need to pay 100 πŸ’Ž to increase bank capacity ~ 1000 sp*"
);
await eco.deduct(user, cara, 100);
await eco.giveCapacity(user, cara, 1000);
await Atlas.sendMessage(
m.from,
{ text: `*1000 πŸ’Ž storage has been added in ${pushname} bank*` },
{ quoted: m }
);
break;
case "10000":
case "2":
if (k > balance.wallet)
return m.reply(
`*You need to pay πŸ’Ž to increase bank capacity ~ 10000 sp*`
);
await eco.deduct(user, cara, 1000);
await eco.giveCapacity(user, cara, 10000);
await Atlas.sendMessage(
m.from,
{
text: `*10000 πŸ’Ž storage has been added in *${pushname}'s* bank*`,
},
{ quoted: m }
);
break;
case "100000":
case "3":
if (k > balance.wallet)
return m.reply(
`*You need to pay 10000 πŸ’Ž to increase bank capacity ~ 100000 sp*`
);
await eco.deduct(user, cara, 10000);
await eco.giveCapacity(user, cara, 100000);
await Atlas.sendMessage(
m.from,
{
text: `*100000 πŸ’Ž storage has been added in *${pushname}'s* bank*`,
},
{ quoted: m }
);
break;
}
break;
case "daily":
await doReact("πŸ“Š");
if (!m.isGroup)
return m.reply("This command can only be used in groups!");
user = m.sender;
const daily = await eco.daily(user, cara, 1000);
if (daily.cd) {
await m.reply(
`🧧 You already claimed your daily revenue today, Come back in ${daily.cdL} to claim again 🫑`
);
} else {
await m.reply(
`You have Successfully claimed your daily revenue ${daily.amount} πŸ’΄ today πŸŽ‰.`
);
}
break;
case "deposit":
await doReact("πŸ’΅");
if (!text) {
return m.reply(
`Please provide an amount to deposit !\n\nExample: *${prefix}deposit 1000*`
);
}
num = parseInt(text);
const deposit = await eco.deposit(user, cara, num);
if (deposit.noten)
return m.reply(
`*Your Deposit ammount should be less than or equal to your wallet balance!*`
);
await Atlas.sendMessage(
m.from,
{
image: debitCard,
caption: `\n⛩️ Sender: ${m.pushName}\n\nπŸ€Successfully Deposited πŸ’΄ ${deposit.amount} to your bank.\n`,
},
{ quoted: m }
);
break;
case "gamble":
await doReact("🎰");
user = m.sender;
var texts = text.split(" ");
var opp = texts[1];
value = texts[0].toLowerCase();
var gg = parseInt(value);
balance = await eco.balance(user, cara);
const g = balance.wallet > parseInt(value);
k = 50;
a = k > parseInt(value);
twice = gg * 2;
const f = [
"up",
"right",
"left",
"down",
"up",
"left",
"down",
"right",
"up",
"down",
"right",
"left",
];
const r = f[Math.floor(Math.random() * f.length)];
if (!text)
return m.reply(
`Usage: *${prefix}gamble 100 left/right/up/down*\n\nExample: *${prefix}gamble 100 left*`
);
if (!value)
return m.reply("*Please, specify the amount you are gambling with!*");
if (!opp) return m.reply("*Specify the direction you are betting on!*");
if (!gg)
return m.reply(
"*Check your text please, You are using the command in a wrong way*"
);
if (g == false)
return m.reply(
`*You don't have sufficient πŸͺ™ Diamond to gamble with*`
);
if (a == true)
return m.reply(
`*Sorry ${m.pushName}, you can only gamble with more than πŸͺ™50.*`
);
if (r == opp) {
await eco.give(user, cara, twice);
await Atlas.sendMessage(
m.from,
{
image: debitCard,
caption: `*πŸ“ˆ You won πŸ’΄ ${twice}*`,
},
{ quoted: m }
);
} else {
await eco.deduct(user, cara, texts[0]);
await m.reply(`*πŸ“‰ You lost πŸ’΄ ${texts[0]}*`);
}
break;
case "leaderboard":
case "lb":
await doReact("πŸ“Š");
try {
let h = await eco.lb("cara", 10);
if (h.length === 0) {
return Atlas.sendMessage(
m.from,
{ text: "No users found on leaderboard." },
{ quoted: m }
);
}
let str = `*[ ${botName} Leaderboard ]*\n\n`;
let arr = [];
for (let i = 0; i < h.length; i++) {
let username = await userData.findOne({
id: h[i].userID,
name: pushname,
});
var tname;
if (username && username.name) {
tname = username.name;
} else {
tname = Atlas.getName(h[i].userID);
}
str += `*${
i + 1
}*\n╭─────────────◆\nβ”‚ *πŸŽ€ Name:-* _${tname}_\nβ”‚ *⚜️ User:-* _@${
h[i].userID.split("@")[0]
}_\nβ”‚ *πŸ’³ Wallet:-* _${h[i].wallet}_\nβ”‚ *πŸ“„ Bank Amount:-* _${
h[i].bank
}_\nβ”‚ *πŸ“Š Bank Capacity:-* _${
h[i].bankCapacity
}_\n╰─────────────◆\n\n`;
arr.push(h[i].userID);
}
await Atlas.sendMessage(
m.from,
{ text: str, mentions: arr },
{ quoted: m }
);
} catch (err) {
console.log(err);
return Atlas.sendMessage(
m.from,
{
text: `An internal error occurred while fetching the leaderboard.`,
},
{ quoted: m }
);
}
break;
case "rob":
await doReact("πŸ’Ά");
if (!text) {
return m.reply(
`Please specify the user you want to rob!\n\nExample: *${prefix}rob @user*`
);
}
if (m.quoted) {
var mentionedUser = m.quoted.sender;
} else {
var mentionedUser = mentionByTag[0];
}
user1 = m.sender;
user2 = mentionedUser;
k = 100;
const amount = Math.floor(Math.random() * 200) + 1;
balance1 = await eco.balance(user1, cara);
balance2 = await eco.balance(user2, cara);
const typ = ["ran", "rob", "caught"];
const random = typ[Math.floor(Math.random() * typ.length)];
if (k > balance1.wallet)
return m.reply(
`*☹️ You don\'t have enough money to pay fine incase you get caught*`
);
if (k > balance2.wallet)
return m.reply(`*☹️ Your target doesn't have enough money to rob*`);
switch (random) {
case "ran":
return m.reply(
`*Lets leave this poor soul alone.*\n\nHe's toooo poor.`
);
case "rob":
await eco.deduct(user2, cara, amount);
await eco.give(user1, cara, amount);
return m.reply(`*πŸ€‘ You robbed and got away with πŸ’΄ ${amount}*`);
case "caught":
await eco.deduct(user1, cara, balance1.wallet);
return m.reply(
`*☹️ You got caught and paid a fine of πŸ’΄ ${balance1.wallet}*`
);
}
break;
case "slot":
await doReact("🎰");
user = m.sender;
var today = new Date();
if (today.getDay() == 6 || today.getDay() == 5 || today.getDay() == 0) {
if (text == "help")
return m.reply(
`*1:* Use ${prefix}slot to play\n\n*2:* You must have πŸͺ™100 in your wallet\n\n*3:* If you don't have money in wallet then withdraw from your bank\n\n*4:* If you don't have money in your bank too then use economy features to gain money`
);
if (text == "money")
return m.reply(
`*1:* Small Win --> +πŸͺ™20\n\n*2:* Small Lose --> -πŸͺ™20\n\n*3:* Big Win --> +πŸͺ™100\n\n*4:* Big Lose --> -πŸͺ™50\n\n*5:* πŸŽ‰ JackPot --> +πŸͺ™1000`
);
const fruit1 = ["πŸ₯₯", "🍎", "πŸ‡"];
const fruit2 = ["🍎", "πŸ‡", "πŸ₯₯"];
const fruit3 = ["πŸ‡", "πŸ₯₯", "🍎"];
const fruit4 = ["πŸ‡", "πŸ₯₯", "🍎"];
const lose = [
"*You suck at playing this game*\n\n_--> 🍍-πŸ₯₯-🍎_",
"*Totally out of line*\n\n_--> πŸ₯₯-🍎-🍍_",
"*Are you a newbie?*\n\n_--> 🍎-🍍-πŸ₯₯_",
];
const smallLose = [
"*You cannot harvest coconut πŸ₯₯ in a pineapple 🍍 farm*\n\n_--> 🍍>πŸ₯₯<🍍_",
"*Apples and Coconut are not best Combo*\n\n_--> 🍎>πŸ₯₯<🍎_",
"*Coconuts and Apple are not great deal*\n\n_--> πŸ₯₯>🍎<πŸ₯₯_",
];
const won = [
"*You harvested a basket of*\n\n_--> 🍎+🍎+🍎_",
"*Impressive, You must be a specialist in plucking coconuts*\n\n_--> πŸ₯₯+πŸ₯₯+πŸ₯₯_",
"*Amazing, you are going to be making pineapple juice for the family*\n\n_--> 🍍+🍍+🍍_",
];
const near = [
"*Wow, you were so close to winning pineapples*\n\n_--> 🍎-🍍+🍍_",
"*Hmmm, you were so close to winning Apples*\n\n_--> 🍎+🍎-🍍_",
];
const jack = [
"*πŸ₯³ JackPot πŸ€‘*\n\n_--> πŸ‡Γ—πŸ‡Γ—πŸ‡Γ—πŸ‡_",
"*πŸŽ‰ JaaackPooot!*\n\n_--> πŸ₯₯Γ—πŸ₯₯Γ—πŸ₯₯Γ—πŸ₯₯_",
"*🎊 You Just hit a jackpot worth πŸͺ™1000*",
];
k = 100;
balance1 = await eco.balance(user, cara);
if (k > balance1.wallet)
return m.reply(
`You are going to be spinning on your wallet, you need at least πŸͺ™100`
);
const f1 = fruit1[Math.floor(Math.random() * fruit1.length)];
const f2 = fruit2[Math.floor(Math.random() * fruit2.length)];
const f3 = fruit3[Math.floor(Math.random() * fruit3.length)];
const f4 = fruit4[Math.floor(Math.random() * fruit4.length)];
const mess1 = lose[Math.floor(Math.random() * lose.length)];
const mess2 = won[Math.floor(Math.random() * won.length)];
const mess3 = near[Math.floor(Math.random() * near.length)];
const mess4 = jack[Math.floor(Math.random() * jack.length)];
const mess5 = smallLose[Math.floor(Math.random() * smallLose.length)];
if (f1 !== f2 && f2 !== f3) {
await eco.deduct(user, cara, 50);
m.reply(`${mess1}\n\n*Big Lose -->* _πŸͺ™50_`);
} else if (f1 == f2 && f2 == f3) {
await eco.give(user, cara, 100);
m.reply(`${mess2}\n*_Big Win -->* _πŸͺ™100_`);
} else if (f1 == f2 && f2 !== f3) {
await eco.give(user, cara, 20);
m.reply(`${mess3}\n*Small Win -->* _πŸͺ™20_`);
} else if (f1 !== f2 && f1 == f3) {
await eco.deduct(user, cara, 20);
m.reply(`${mess5}\n\n*Small Lose -->* _πŸͺ™20_`);
} else if (f1 !== f2 && f2 == f3) {
await eco.give(user, cara, 20);
m.reply(`${mess3}\n\n*Small Win -->* _πŸͺ™20_`);
} else if (f1 == f2 && f2 == f3 && f3 == f4) {
await eco.give(user, cara, 1000);
m.reply(`${mess4}\n\n_🎊 JackPot --> _πŸͺ™1000_`);
} else {
m.reply(`Do you understand what you are doing?`);
}
} else {
m.reply(
`*You can only play this game during weekends*\n\n*🌿 Friday*\n*🎏 Saturday*\n*🎐 Sunday*`
);
}
break;
case "transfer":
await doReact("πŸ’΄");
if (value[0] === "") return m.reply(`Use ${prefix}transfer 100 @user`);
if (!text && !m.quoted) {
return Atlas.sendMessage(
m.from,
{ text: `Please tag any user ${pushName} senpai πŸ€¦β€β™‚οΈ !` },
{ quoted: m }
);
} else if (m.quoted) {
var mentionedUser = m.quoted.sender;
} else {
var mentionedUser = mentionByTag[0];
}
user = (await mentionedUser) || m.msg.contextInfo.participant;
user1 = m.sender;
user2 = user;
const word = value[0];
const code = value[1];
d = parseInt(word);
if (!d)
return m.reply(
"check your text plz u r using the command in a wrong wayπŸ‘€"
);
balance = await eco.balance(user1, cara);
a = balance.wallet < parseInt(word);
if (a == true)
return m.reply("you dont have sufficient money to transferπŸ‘Ž");
await eco.deduct(user1, cara, value[0]);
await eco.give(user2, cara, value[0]);
await Atlas.sendMessage(
m.from,
{
image: debitCard,
caption: `*πŸ“  Transaction successful of ${word} πŸ’·*`,
},
{ quoted: m }
);
break;
case "wallet":
await doReact("πŸ’²");
user = m.sender;
balance = await eco.balance(user, cara);
await Atlas.sendMessage(
m.from,
{
image: debitCard,
caption: `\nπŸ’³ *${m.pushName}'s Wallet:*\n\n_πŸ’΄ ${balance.wallet}_`,
},
{ quoted: m }
);
break;
case "withdraw":
await doReact("πŸ’³");
if (!text) {
return m.reply(`*Provide the amount you want to withdraw!*`);
}
user = m.sender;
query = text.trim();
withdraw = await eco.withdraw(user, cara, query);
if (withdraw.noten) return m.reply("*🏧 Insufficient fund in bank*");
await eco.give(user, cara, query);
Atlas.sendMessage(
m.from,
{
image: debitCard,
caption: `*🏧 ALERT* _πŸ’Ά ${withdraw.amount} has been added in your wallet._*`,
},
{ quoted: m }
);
break;
default:
break;
}
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment