Skip to main content
In this recipe you build a full coins system:
  • /balance: see your coins.
  • /work: earn coins, with a lucky bonus.
  • /give: give coins to a friend.
  • /buy-vip: spend 500 coins on a VIP role.
  • /add-coins: staff only, add coins to anyone.

Step 1: Make the variable

On the Database page, make one variable: Now {DBVAR_coins} means “the coins of the person using the command”. Need help? See Make your first variable.

Step 2: /balance

  1. Make a new Slash command called balance, description See your coins.
  2. Add a Reply block under the first block and connect it.
  3. Type: You have {DBVAR_coins|0} coins.
  4. Save.
The |0 is a backup, so a brand new member sees 0 instead of nothing.

Step 3: /work

  1. Make a slash command called work.
  2. Add Do the maths. Variable: coins. Whose variable: the person who used the command. Maths: + 25.
  3. Add a Random chance check under it, set to 10%.
  4. On the yes path: another Do the maths, + 100, then a Reply: Lucky day! You earned 25 coins plus a 100 coin bonus. You now have {DBVAR_coins}.
  5. On the else path: a Reply: You worked hard and earned 25 coins. You now have {DBVAR_coins}.
  6. Save.

Step 4: /give

This one uses Inputs: the boxes people fill in.
  1. Make a slash command called give.
  2. From the Inputs tab, add a User input called member and a Number input called amount. Make both required.
  3. Add a Compare check: is {DBVAR_coins} greater than or equal to the amount? (Use the Variables button to pick the amount input’s value.)
  4. On the yes path:
    • Do the maths on coins, whose variable: the person who used the command, maths: minus the amount.
    • Do the maths on coins, whose variable: the member from the input, maths: plus the amount.
    • Reply: You gave coins to your friend!
  5. On the else path: Reply: You don't have enough coins. You have {DBVAR_coins}.
  6. Save.
Always check first, then take the coins, then give them. Otherwise people could give away coins they do not have.

Step 5: /buy-vip (a shop)

  1. Make a slash command called buy-vip.
  2. Add Compare: is {DBVAR_coins} greater than or equal to 500?
  3. On the yes path:
    • Do the maths on coins: - 500.
    • Give roles: pick your VIP role.
    • Reply: You bought VIP! You have {DBVAR_coins} coins left.
  4. On the else path: Reply: VIP costs 500 coins. You have {DBVAR_coins}.
  5. Save.
Your bot’s own role must be above the VIP role in your server’s role list, or Discord will not let it give that role.

Step 6: /add-coins (staff only)

  1. Make a slash command called add-coins with a User input member and a Number input amount.
  2. Add a check that looks at the permissions of the person who used it (type permission into the block search). Choose Administrator.
  3. On the yes path: Do the maths on coins, whose variable: the member from the input, maths: plus the amount. Then Reply: Done!
  4. On the else path: Reply: Only admins can use this.

Make it yours

  • Show coins on a picture: make a wallet card in Card Studio with {DBVAR_coins} on it. See Card Studio.
  • Sell more things: copy /buy-vip and change the price and role.
  • Use a User -> Object variable called wallet with keys coins and gems for two kinds of money. See Objects and Collections.