Basic Economy [Aoi.js]
This will show you the Code for Economy and an Explanation (Short because its self explanatory)
Code
index.js - Variables
client.variables({ money: "0", bank: "0"})
variables.js - Variables
Requires require("./variables.js")(client);
in index.js
module.exports = (client) => { client.variables({ money: "0", bank: "0" }, "main"); };
balance.js
module.exports ={ name: "balance", aliases: ["bal"], code: ` $title[$username[$mentioned[1]]'s Balance] $description[Money:- \`$getUserVar[money;$mentioned[1]]$\`Bank- \`$getUserVar[bank;$mentioned[1]]$\`] $color[Yellow]`}
beg.js
module.exports ={ name: "beg", code: ` $description[$randomText[Poor guy, here $get[randommoney]$;You are still begging? Unbeliavable, here $get[randommoney]$;You picked up some trash and put it into trash can, a guy gave you $get[randommoney]$ for that.]] $color[Yellow] $setUserVar[money;$sum[$getUserVar[money];$get[randommoney]]] $let[randommoney;$random[1;10]] $cooldown[5s]`}
daily.js
module.exports ={ name: "daily", code: ` $title[Daily Reward Claimed] $description[You claimed your daily reward- And received: 100$] $color[Yellow] $setUserVar[money;$sum[$getUserVar[money];100]] $cooldown[24h;Slow down bud, you can't claim your daily reward again, you still have %time% left.]`}
weekly.js
module.exports ={ name: "weekly", code: ` $title[Weekly Reward Claimed] $description[You claimed your Weekly Reward- And received 1000$] $color[Yellow] $setUserVar[money;$sum[$getUserVar[money];1000]] $cooldown[7d;Your cooldown is still active, ( %time% Left)]`}
monthly.js
module.exports ={ name: "monthly", code: ` $title[Monthly Reward Claimed] $description[You claimed your Monthly Reward- And received 10,000$] $color[Yellow] $setUserVar[money;$sum[$getUserVar[money];10000]] $cooldown[31d;Your cooldown is still active, ( %time% Left )]`}
deposit.js
module.exports =[{ name: "deposit", code: ` $description[How much do you want to deposit, $username?] $color[Yellow] $addButton[1;Input;secondary;input;false]`},{ name: "input", type: 'interaction', prototype: 'button', code: ` $interactionModal[Deposit Money;depositid; {actionRow: {textInput: How much you want to deposit?:1:depositid1:false::1:10}}]`},{ name: "depositid", type: 'interaction', prototype: 'modal', code: ` $interactionReply[;{newEmbed: {description: $textInputValue[depositid1] has been deposited into your bank.} {color: Yellow}}] $setUserVar[money;$sub[$getUserVar[money];$textInputValue[depositid1]]] $setUserVar[bank;$sum[$getUserVar[bank];$textInputValue[depositid1]]]] $onlyIf[$textInputValue[depositid1]<=$getUserVar[money];You don't have enough money to deposit that much.]`}]
withdraw.js
module.exports =[{ name: "withdraw", code: ` $description[How much do you want to withdraw, $username?] $color[Yellow] $addButton[1;Input;secondary;input2;false]`},{ name: "input2", type: 'interaction', prototype: 'button', code: ` $interactionModal[Withdraw Money;withdrawid; {actionRow: {textInput: How much you want to withdraw?:1:withdraw1:false::1:10}}]`},{ name: "withdrawid", type: 'interaction', prototype: 'modal', code: ` $interactionReply[;{newEmbed: {description: $textInputValue[withdraw1] has been withdraw from your bank.} {color: Yellow}}] $setUserVar[bank;$sub[$getUserVar[bank];$textInputValue[withdraw1]]] $setUserVar[money;$sum[$getUserVar[money];$textInputValue[withdraw1]]]] $onlyIf[$textInputValue[withdraw1]=>$getUserVar[money];You don't have enough money to withdraw that much.]`}]
Explanation
Balance
- Usage:
[prefix]balance @user
- Check User’s Balance by pinging them, we use
$getUserVar
to get information about their Money & Bank
Beg
- Usage:
[prefix]beg
- Beg for some coins, we use
$let
to save it as a temporary variable,$random
to generate random number of coins, and$setUserVar
to finally save coins user was given!
Daily
- Usage:
[prefix]daily
- Get your Daily coins, we use classic
$setUserVar
+$sum
combo to give user their coins! Example usage:$setUserVar[money;$sum[$getUserVar[money];100]]
. We also add$cooldown[24h]
to prevent users from abusing the command!
Weekly
- Usage:
[prefix]weekly
- Get your Weekly coins, its same as Daily, same usages, but
$cooldown
increased to 7D / 7 Days. Also user gets more coins from Weekly than Daily!
Monthly
- Usage:
[prefix]monthly
- Get your Monthly coins, its same as Weekly, same usages, but
$cooldown
increased to 31D / 31 Days. Also user gets more coins from Monthly than Weekly!
Deposit
- Usage:
[prefix]deposit [amount of coins to deposit]
- Here we use $interactionModal to ask user to Input amount they want to Deposit to their Bank. When they press “Submit” Bot will deposit the Coins, it does that by using
$setUserVar
+$sub
to take away coins from main account, then$setUserVar
+$sum
to add coins to the bank!
If user tries to deposit more than they can, it will return an error message
Withdraw
- Usage:
[prefix]withdraw [amount of coins to withdraw]
- Same as deposit, but only thing that has changed is now its opposite for setting variables
$setUserVar
+$sub
to take coins from Bank, then$setUserVar
+$sum
to give User the coins they withdrawn!
If user tries to withdraw more then they have in Bank it will return an Error Message
End
- Thanks to anyone who is still Following me on Youtube Channel and actually uses codes I make, appreciate that!
- Hope you liked this Basic Economy!
Credits
JosipFX - Made Code & Video