Created
August 31, 2023 17:05
-
-
Save FantoX/63bcf78d6da0bce7d9f18343e3143fbc to your computer and use it in GitHub Desktop.
All Economy and Gambling commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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