Starts with a slash command

Coin shop

Members claim 50 coins a day with /daily and save up for what you put in /shop: a name color for 200, a custom role for 500. Items and prices are yours to set.

Illustration. The real interface may look different.

How it works

  1. /daily adds coins to a member's balance, once per day.

  2. /shop lists your items with the prices you set.

  3. Buying checks the balance, takes the coins and adds the item to the member's inventory.

  4. A purchase is a single operation, so two fast clicks can't spend the same coins twice.

How to make a coin shop on Discord

A wallet, a date and a list per member are all the data this economy needs. Coins are only ever moved by steps that check and write in one go.

Describe it to your AI assistant

I want members to have a reason to check in every day. Build a coin shop module: /daily gives 50 coins once per day, /shop shows three items with a buy button each, and /inventory lists what a member has bought. A purchase must take the coins in one step that only works while the balance covers the price, so two fast clicks cannot spend the same coins twice, and refund the price if saving the item fails. Make the currency name, the daily reward and the name and price of each item settings.

Copy it and swap in your own channel and role names. Your assistant has a tested version of this example to start from.

Build it in the editor

Four kinds of flow: /daily, /shop, a buy flow per item button and /inventory. The buy flow is the one to get right, because it takes coins.

The 4 flows, step by stepStep names are the ones the editor shows.

Flow 1/daily

Trigger: Slash command/daily.

  1. Current date/timeTakes today's date.
  2. Set stored value if (atomic)Claims today for this member. A second /daily on the same day stops here with the current balance.
  3. Increment if (atomic)Credits the daily reward to the wallet.
  4. Reply to interactionAnswers with the new balance.

Flow 2/shop

Trigger: Slash command/shop.

  1. Create messageBuilds the catalogue from your item settings, with a buy button per item.
  2. Reply to interactionAnswers the command with it.

Flow 3Buy

Trigger: Button clickedfrom the buy button of an item, one flow per item.

  1. Increment if (atomic)Takes the price out of the wallet, but only while the balance still covers it. If it does not, the member is told what is missing.
  2. Build a shape valueBuilds the purchase: item, price and buyer.
  3. TryWraps the next step, and refunds the exact price if it fails.
  4. Add item to stored listAdds the purchase to the member's inventory.
  5. Reply to interactionConfirms with the coins that are left.

Flow 4/inventory

Trigger: Slash command/inventory.

  1. Read a stored valueReads the member's purchases.
  2. For each itemGoes through them.
  3. Get a field of a shape valueTakes item name and price out of each.
  4. Create messageBuilds the list. The tested version shows the ten most recent purchases.

Test it, change it

What it stores

  • WalletPer userThe coin balance per member. New members start with your starting balance.
  • Last daily claimPer userThe date of each member's last /daily.
  • InventoryPer userPer member: the list of purchases with item, price and buyer.

How to test it

  1. Open a flow in the editor and click "Test run". Choose the member under "Run as" and click "Run test". The run uses your real server data but sends, changes and deletes nothing, and shows what each step would have done.
  2. A new flow is a "Draft" and does not run in Discord. Switch it on and click "Save & activate".
  3. Run /daily twice in Discord: the second time pays nothing. Then buy an item with a double click on its button and check with /inventory that it was bought once.
  4. Each real run then shows up under "Executions", with the reason if it failed or was skipped.

What to change

Items and prices
Name and price of each item are settings in the module's "Configuration" tab.
Daily reward
The "Daily reward" setting. "Starting balance" is what a new member gets.
Currency
The "Currency name" setting replaces "coins" in every message.
A fourth item
Needs two more settings, a button and a buy flow.

Watch out for

  • Buying only records the purchase. An item does nothing until you add a step for it, such as "Add role to member" for a role.
  • The day for /daily changes at midnight in your bot's timezone.
  • Changing "Starting balance" later affects new members only.

Questions about this build

Can an item give a role when it is bought?

Yes. Add "Add role to member" to that item's buy flow, after the purchase is saved. The bot's role has to sit above the role it gives.

Can members earn coins by chatting?

Yes. Add a flow on a "Message created" trigger with a cooldown that raises the wallet, the same way the level example hands out XP.

Can I give or take coins as an admin?

Edit the member's wallet under "Stored data" in the dashboard, or ask your assistant for a /coins command limited to your team.

想让你的服务器加入公测吗?

V3 是个庞大的系统,而且迭代很快,所以服务器是逐个加入的,而不是一次全部放进来。每份申请都由真人阅读,几天内你就会收到回复。

已经加入公测的服务器,在很大程度上决定了我们接下来做什么。你搭建的东西归你所有:公测结束后,Flows 和模块都会保留。