Public
NexusMarket: gaming shop with Discord order verification
discordecommercemarketplacereactsqlite
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

NexusMarket

A Minecraft item shop where every order is verified over Discord before it reaches the seller.

Buyers check out with their Discord handle and their Minecraft IGN. They get a one-time order code, the bot DMs them about it, and once the code checks out the bot asks them “are these your items?”. Tapping Yes DMs the seller the items, the buyer's IGN and their Discord handle.

Open the shop · Seller dashboard · Track an order

The order flow

Rendering mermaid diagram...

The site's own Yes / No buttons call the exact same code as the Discord ones, so an order behaves identically either way — and the whole flow still works if Discord isn't connected yet (you just get a warning instead of a DM).

Set up the Discord bot

You need a bot before any DMs will send. Fifteen minutes, once.

  1. Go to the Discord Developer Portal → New Application. Name it NexusMarket.
  2. Bot tab → Reset Token → copy it. That's DISCORD_BOT_TOKEN.
  3. On the same page, turn Server Members Intent on (NexusMarket uses it to turn a Discord username into a user ID).
  4. General Information tab → copy Public Key. That's DISCORD_PUBLIC_KEY.
  5. Still on General Information, set Interactions Endpoint URL to the live URL of interactions.ts: https://pyroproxies--eaa920dac83211f19bd41607ee4eb77e.web.val.run Discord immediately POSTs a signed ping to it — if it saves without an error, your public key is correct. (It will fail until DISCORD_PUBLIC_KEY is saved below, so do that first.)
  6. OAuth2 → URL Generator → scopes bot + applications.commands, permissions Send Messages. Open the generated URL and invite the bot to your server. The bot must share a server with a buyer to DM them.
  7. Get your own numeric user ID: Discord → Settings → Advanced → Developer Mode on, then right-click your name → Copy User ID. That's DISCORD_OWNER_ID, and it's where confirmed orders land.

Paying: real money or in-game money

Every item can carry two prices in server/catalog.ts:

{ id: "mc-netherite-sword", price: 8.99, // real money (USD) priceIg: 5_000_000, // in-game money, paid on the server ... }

At checkout the buyer picks one, and that choice travels with the order the whole way: the item list, the totals in Discord, and the amount the seller is told to collect. In-game orders show up in the seller's DM as "collect 21,000,000$ in game".

Leave priceIg off an item (or set it to 0) and it becomes real money only — the card shows "real money only", and switching the cart to in-game money blocks checkout with an itemised reason. That's the right setting for store ranks and for selling in-game money itself, which you can't pay for with in-game money.

GAME_NAME and SERVER_NAME label all of this in the UI; the currency is described by IG_LABEL in the catalog file.

Environment variables

KeyWhat it's for
DISCORD_BOT_TOKENBot token. Without it the shop runs but sends no DMs.
DISCORD_PUBLIC_KEYVerifies that button clicks really came from Discord.
DISCORD_GUILD_IDYour server's ID — used to resolve a buyer's username to an ID.
DISCORD_OWNER_IDYour numeric user ID. Confirmed orders are DMed here.
DISCORD_OWNER_USERNAMEOptional. Defaults to shawtythehottie123.
GAME_NAMEOptional. Label shown to buyers; defaults to Minecraft.
SERVER_NAMEOptional. Your server's name, shown in the hero badge.
ADMIN_KEYOptional but recommended. Unlocks /admin.
PAYMENT_LINKOptional. A PayPal/Cash App link shown at checkout.

Set them in the val's environment variables — the site tells you when the bot isn't wired up yet, and every API response carries a warning explaining what was skipped.

Editing the catalog

Items live in server/catalog.ts and are seeded into SQLite. Change prices, names, enchants and delivery times there, then bump SEED_VERSION — the catalog table is replaced wholesale on the next request, so adding, removing and repricing items all work the same way. Categories ("Gear", "Currency", "Spawners & Rare", …) become the filter chips automatically.

Already-placed orders are never touched: each order stores its own snapshot of item names and prices.

Admin

/admin lists every order with the buyer's Discord handle, IGN, items, total and status, behind the ADMIN_KEY. pending means the buyer hasn't entered their code yet; awaiting_confirmation means they're looking at the items; confirmed means you've already been DMed.

Files

index.ts                  Hono server: pages + public API
interactions.ts           Discord Interactions Endpoint URL handler
server/
  catalog.ts              The Minecraft item catalog (edit me)
  db.ts                   SQLite schema, items and orders
  discord.ts              Discord REST helpers + message builders
  flow.ts                 purchase → verify → confirm → notify-the-seller
frontend/
  root.tsx                HTML shell
  lib/api.ts              Client types, fetch helpers, tiny router
  components/
    App.tsx               Layout, cart, routing
    Store.tsx             Hero, how-it-works, catalog grid
    Checkout.tsx          Discord handle + IGN, order code screen
    Verify.tsx            "Are these your items?" confirmation
    Admin.tsx             Seller dashboard
    ui.tsx                Shared UI primitives

Notes

  • No gateway connection: Val Town can't hold a WebSocket open, so the bot is purely outbound REST plus Discord's HTTP interactions endpoint.
  • Prices are always recomputed server-side from the database, never trusted from the browser.
  • Order codes skip 0/O/1/I/L so they're easy to read off a screen and retype.