Economy Integration

Integrate Nevi's economy system into custom commands. Add currency, remove currency, check balances, and build economy-gated features.

Adding currency

The {economyAdd(amount)} function gives currency to the user who runs the command. This lets you create custom reward commands, daily bonus alternatives, or mini-games with payouts.

Syntax

{economyAdd(amount)}

amount - The number of currency units to add to the user's balance. Must be a positive number.

Example: Bonus command

/customcmd create bonus {user.name} received a bonus of 50 coins! {economyAdd(50)}

Every time a user runs /bonus, they receive 50 coins.

Example: Random reward

/customcmd create loot {reward = random(10,25,50,100)}{user.name} found a treasure chest containing {reward} coins! {economyAdd({reward})}

Picks a random amount and awards it to the user with a fun narrative.

Removing currency

The {economyRemove(amount)} function takes currency from the user who runs the command. Use this for costs, fees, penalties, or pay-to-use features.

Syntax

{economyRemove(amount)}

amount - The number of currency units to remove from the user's balance.

Example: Fee command

/customcmd create vip {user.name} paid 100 coins for VIP access! {economyRemove(100)}

Important

It's best practice to combine {economyRemove()} with a balance check using {if()} and {economyBalance()} to make sure the user can actually afford the cost. See the Conditional Economy section below for examples.

Checking balance

The {economyBalance()} function returns the current currency balance of the user who runs the command. This is useful on its own for display or combined with conditionals for economy-gated logic.

Syntax

{economyBalance()}

Returns the user's current balance as a number.

Example: Balance display

/customcmd create wallet {user.name}'s wallet: {economyBalance()} coins

A simple command that shows how many coins the user has.

Example: Rich embed balance

/customcmd create bank {embed.title:"{user.name}'s Bank".field:"Balance|{economyBalance()} coins|inline".color:"#FFD700"}

Displays the user's balance in a gold-themed embed.

Conditional economy

Combine economy functions with the {if()} conditional. This lets you create commands that check if a user can afford something before charging them, creating economy-gated features.

Pattern: Check before charging

{if({economyBalance()} >= cost:success message {economyRemove(cost)}:failure message)}

This pattern checks if the user has enough currency. If they do, it runs the success branch and removes the cost. If not, it shows an error message without taking anything.

Example: Pay-to-use fortune

/customcmd create fortune {if({economyBalance()} >= 25:You paid 25 coins. Your fortune: {random(Great riches await you,Love is on the horizon,A challenge approaches,You will find what you seek,Expect the unexpected)} {economyRemove(25)}:You need at least 25 coins! You only have {economyBalance()}.)}

Costs 25 coins to use. If the user can afford it, they get a random fortune. If not, they see how much they need.

Example: VIP access check

/customcmd create viproom {if({economyBalance()} >= 500:Welcome to the VIP room, {user.name}! Entry fee: 500 coins. {economyRemove(500)} Your remaining balance: {math({economyBalance()} - 500)} coins.:Sorry {user.name}, VIP access costs 500 coins. You have {economyBalance()} coins.)}

Creative examples

Here are some more advanced examples of economy integration in custom commands.

Lottery command

/customcmd create lottery {if({economyBalance()} >= 50:{result = random(lose,lose,lose,lose,win)}{if({result} = win:You paid 50 coins and WON 500 coins! {economyRemove(50)} {economyAdd(500)}:You paid 50 coins and lost. Better luck next time! {economyRemove(50)})}:You need 50 coins to play the lottery. You have {economyBalance()}.)}

A lottery with a 1 in 5 chance of winning. Costs 50 coins to play; winners get 500 coins (net +450). The odds favor the house, making it a fun money sink.

Coin flip gamble

/customcmd create coinflip {if({economyBalance()} >= 100:{flip = random(heads,tails)}{if({flip} = heads:Heads! You won 100 coins! {economyAdd(100)}:Tails! You lost 100 coins. {economyRemove(100)})}:You need at least 100 coins to gamble. Balance: {economyBalance()}.)}

A 50/50 coin flip that doubles or takes 100 coins.

Donation command

/customcmd create donate {if({args.count} > 0:{if({economyBalance()} >= {args.0}:{user.name} donated {args.0} coins to the server fund! {economyRemove({args.0})}:You don't have {args.0} coins. Balance: {economyBalance()}.)}:Usage: /donate <amount>)}

Lets users donate a specified amount of coins. Validates that they provided an amount and can afford it.

Balance check embed

/customcmd create mycoins {embed.title:"{user.name}'s Wallet".description:"Here's your current financial status.".color:"#FFD700".field:"Balance|{economyBalance()} coins|inline".field:"Can afford lottery?|{if({economyBalance()} >= 50:Yes:No)}|inline"}

A styled embed that shows the user's balance and whether they can afford to play the lottery.

Related Commands

/customcmdmanagementRequires mod

Create and manage custom commands with template support