> ## Documentation Index
> Fetch the complete documentation index at: https://docs.joinmarkt.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Discord bot

> Connect your own Discord bot to give buyers roles and run your store with slash commands.

Your Discord bot gives buyers a role after they pay, and lets your staff check orders, stock and coupons without leaving Discord.

It is **your** bot. You create it in Discord, and Join Markt runs its commands. The bot shows as offline in the member list. That is normal: it answers through Discord's web endpoint, not a live connection.

> [card] Buyer roles
>
> Paid buyers get a role on their own, or with one button.

> [card] Store commands
>
> Stock, orders, coupons and prices from any channel.

> [card] Staff only
>
> Store commands need **Manage Server** by default.

## Set up

**1. Create a Discord application**

Open the [Discord Developer Portal](https://discord.com/developers/applications) and press **New Application**.

Under **Bot**, press **Reset Token** and copy the token. Under **OAuth2**, copy the **Client ID** and **Client Secret**.

**2. Paste the keys in Join Markt**

In the dashboard, go to **Configure → Discord bot**. Paste the Client ID, Client Secret and Bot Token, then press **Save settings**.

Join Markt then sets the bot's **Interactions Endpoint URL** in Discord for you.

**3. Add the redirect URIs**

The **Setup guide** card shows two redirect URIs. In the Developer Portal, open **OAuth2 → Redirects** and add both:

| URI | Used for |
| - | - |
| Bot invite | adding the bot to your server |
| Buyer link | buyers linking Discord at checkout |

**4. Invite the bot**

Press **Invite bot to server** and pick your server. The bot asks for **Manage Roles**.

> [!WARNING]
>
> In **Server Settings → Roles**, drag the bot's role **above** every role it gives. Discord does not let a bot give a role higher than its own.

**5. Pick the roles**

* **Per product:** open a product, then **Discord role delivery**. Pick a server and a role.
* **For every buyer:** set **Default customer role ID** in **Configure → Discord bot**.

**6. Post the claim panel**

In the channel where buyers should claim, run `/roles panel`. It posts a message with a **Claim role** button.

## How buyers get their role

| Way | What the buyer does | When the role arrives |
| - | - | - |
| Automatic | Links Discord at checkout, or enters their Discord ID in a checkout field | Right after payment |
| Claim panel | Presses **Claim role**, enters order email + order ID | Right away |
| Command | Runs `/claim email order_id` | Right away |
| Staff | Staff runs `/roles grant` | Right away |

The order must be **paid**, **completed** or **delivered**, and the email must match the order. Each role is given once per order.

The buyer must already be a member of your server. Set **Customer server invite URL** so checkout shows a **Join** link.

> [!NOTE]
>
> At checkout, the Discord link only keeps the buyer's email when it matches the verified email on their Discord account. If it does not match, the account is still linked, but the role is not given on its own. The buyer then uses the claim panel or `/claim`.

## Commands

Store commands need **Manage Server**. You can change who sees them in **Server Settings → Integrations → your bot**. `/claim` and `/help` work for everyone.

Replies are only visible to the person who ran the command, except the claim panel.

> [accordion] Store
>
> | Command | What it does |
> | - | - |
> | `/store overview` | Revenue and paid orders for 30 days, all-time revenue, products, keys in stock |
> | `/store ping` | Checks the bot is linked to your store |
> | `/store sync` | Refreshes the commands in this server |

> [accordion] Products
>
> | Command | What it does |
> | - | - |
> | `/product view product` | Price, visibility, stock, role and ID, with an **Edit product** button |
> | `/product price product amount` | Changes the price. Shows old → new |
> | `/product visibility product visibility` | Public, Unlisted, On hold or Private |

> [accordion] Stock
>
> | Command | What it does |
> | - | - |
> | `/stock view product [variant]` | Keys left for one product |
> | `/stock list` | Stock for up to 20 products, lowest first |
> | `/stock add product [keys] [file] [variant]` | Adds keys. Paste them, or upload a `.txt` file with one key per line |
>
> `/stock add` takes up to **5,000 keys** and files up to **512 KB**. Keys can be split by new lines, commas or semicolons.

> [accordion] Orders
>
> | Command | What it does |
> | - | - |
> | `/order view order_id` | Status, total, payment, product, customer, time, with an **Open order** button |
> | `/order recent [limit]` | The latest 1–15 orders |

> [accordion] Coupons
>
> | Command | What it does |
> | - | - |
> | `/coupon view code` | Discount, status and uses |
> | `/coupon create code type value [usage_limit]` | New percent or fixed coupon. Percent must be 1–100. Codes must be new |
> | `/coupon toggle code active` | Turns a coupon on or off |

> [accordion] Customers
>
> | Command | What it does |
> | - | - |
> | `/customer top [limit]` | Buyers who spent the most, 1–25 |
> | `/customer lookup user` | Linked account, email, and every role the bot gave the member |

> [accordion] Roles
>
> | Command | What it does |
> | - | - |
> | `/roles panel` | Posts the **Claim role** message |
> | `/roles grant user order_id` | Gives a member the roles of a paid order |
> | `/roles revoke user` | Removes every role the bot gave a member, and clears the records |

> [accordion] Everyone
>
> | Command | What it does |
> | - | - |
> | `/claim email order_id` | Gets your buyer role |
> | `/help` | Lists the commands |

Product and coupon options search as you type.

## Fix common problems

> [accordion] The commands do not show up
>
> Press **Sync slash commands** in **Configure → Discord bot**, or run `/store sync`. Then restart Discord.

> [accordion] You must join this Discord server first
>
> The buyer is not a member yet. They join with your invite link, then claim again.

> [accordion] The role is not given
>
> * Check the bot's role sits **above** the role it gives.
> * Check the product has a role in **Discord role delivery**, or a default customer role is set.
> * Check the order is paid.

> [accordion] This command is out of date
>
> The server still has old commands. Run **Sync slash commands** once.

## API

Read and change the bot settings with an API key: [Merchant Discord](https://docs.joinmarkt.com/api-reference/merchant-discord.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.