---
url: https://docs.sunlicense.com/guide/discord.md
---
# Discord

Run licensing where your community already is. Connect your Discord server to SunLicense and:

* **manage licenses from Discord** with `/license` (autocomplete, buttons, your dashboard permissions),
* get **staff notifications**, including a red **key-sharing alert** with a *Suspend* button,
* let **customers claim** their license, get **buyer roles** that follow the license, see their machines and **free a slot themselves**,
* run **key drops**: N fresh licenses, one per member, with a live count of the keys left,
* see **charts in chat** with `/stats` and a daily digest.

## Connect your server

You need the `org.manage` permission in SunLicense (Owners and Admins have it) and **Manage Server** in Discord.

1. In the dashboard, open **Discord** and click **Add to Discord**. Pick your server.
2. Click **Create setup code** and paste the command into any channel of that server:
   ```
   /sunlicense setup code:ABCD-EFGH
   ```
   The code works once, for 15 minutes. Notifications start in the channel where you ran it.

Running `setup` also links your own Discord account to your SunLicense account.

## Link your Discord account (staff)

Each staff member links their own account: dashboard → **Discord** → **Create link code**, then in Discord (in the server, or in a DM with the bot):

```
/sunlicense link code:WXYZ-2345
```

Your Discord account now acts as you. A Viewer can look up licenses but not revoke them, exactly as in the dashboard; if an admin disables your account or changes your role, Discord follows within 30 seconds. `/sunlicense unlink` (or *Unlink* in the dashboard) undoes it.

Staff in **more than one organization** (say you help two sellers) link the same Discord account once in each: create a link code in each organization's dashboard and run `/sunlicense link` with it. In an organization's server your commands act only for that organization. In a DM with the bot they act for your organization when you have one; with several, the bot asks you to run the command in that organization's server. Unlinking in a server, or with *Unlink* in an organization's dashboard, removes only that organization's link.

Staff commands are visible to members with **Manage Server** by default. To open them to your support team, go to **Server Settings → Integrations → SunLicense** and allow their role. To use them anywhere, even in DMs, add the app to your Discord account with the link on the dashboard page.

## Staff commands

| Command | What it does |
|---|---|
| `/license view license:` | The license card (status, expiry, machines), the customer and, when the policy has an [IP limit](/guide/concepts#ip-limits), how many IP addresses are in use. Buttons: *Reveal key*, *Machines*, *Suspend*/*Reinstate* and *More*, which swaps the row for *IP addresses*, *Revoke…* and *Back*. *Revoke…* asks in a form whether to revoke for good or suspend instead |
| `/license issue [policy:] [deliver_to:@member]` | A form for the policy, email and name. With `deliver_to`, the member gets the license by DM (key behind a spoiler), it's claimed for them and their buyer roles are given |
| `/license machines license:` | Active machines with hostnames, fingerprints and last-seen times; pick one to free its slot |
| `/license ips license:` | For an IP-limited license, the IP addresses in use (only you see this reply); pick one to free it |
| `/stats [range:]` | Validation chart (24 h, 7 or 30 days) with the total, trend and share of valid checks; buttons switch the range |
| **Apps → Licenses** (right-click a member) | The licenses that member claimed |
| `/sunlicense notifications` | Pick the channel and events, then *Send a test* |
| `/sunlicense roles product: [role:]` | Give members a role for each product they own (or *Any product* for a verified-buyer role). Leave `role` empty to stop |
| `/sunlicense panel` | Post the claim panel for customers in the current channel |
| `/drop policy: count: [title:]` | Start a key drop |
| `/sunlicense status` | What's connected and who you are, with *Notifications* and *Buyer roles* buttons |

The `license:` option searches as you type: a key, its first group (`AX8P`), or the customer's email.

Everything staff see is private to them (ephemeral). Keys are always masked (`AX8P-XXXX-XXXX-XXXX`) until you press *Reveal key*, which answers only to you.

## Notifications

| Event | On by default |
|---|---|
| License issued, suspended, reinstated, revoked | yes |
| **Possible key sharing**: a license refused because all its machines (or IP addresses) are in use; the post never shows the address | yes |
| New machine activated | no (busy servers get many) |
| Plan changed | yes |
| Daily digest at 09:00 UTC: chart of the last 7 days and headline numbers | yes |
| **Automation messages**: what your [automations](/guide/automation-webhooks#post-in-discord) post with *Post in Discord* | yes |

Suspended and reinstated notifications are posted only when someone actually changes the license's status. Editing a license or its customer doesn't post anything. When a lot happens at once (an import or a bulk revoke), each server gets at most 10 license notifications a minute, and the rest arrive as one summary such as "14 more changes · 12 issued, 2 revoked".

Key-sharing alerts show where the refused attempt came from (city and country), that every slot is in use, the hostname and the masked key, with *Suspend*, *View license*, *Free a slot* and *Ignore* buttons (your SunLicense permissions apply). When someone suspends or ignores, the alert turns grey and says who ("Suspended by @maya"). There is at most one alert per license every 15 minutes.

Notifications show customer names and masked emails (`ja•••@example.com`), never full emails or keys: a staff channel is often wider than the people who should see buyers' details.

You can also pick the channel and events, or turn off self-service resets, in the dashboard.

## For your customers

Post the claim panel once (`/sunlicense panel`), or tell customers about the commands:

| Command | What it does |
|---|---|
| **Claim a license** / `/claim` | A form asking for the **license key and the purchase email**. Both must match, so a leaked key alone can't be claimed. A license can be claimed by one Discord account |
| **My licenses** / `/my-licenses` | Their licenses with status and machine usage; *Open* shows the license card with *Reveal key* (private) and *Reset a machine* |

**Buyer roles** follow the license: given on claim, removed when the license is revoked, suspended or expires, given back on reinstate. Drag the **SunLicense** role above the buyer roles in **Server Settings → Roles**, or Discord won't let the bot assign them.

### Your brand in Discord

What your customers see carries your [branding](/guide/branding): the claim panel, their license cards, `/my-licenses`, licenses sent to them by DM, and key drops show your logo and the name customers see, with your accent colour on the panel's colour bar and the top edge of its image (Lite and Standard). License status colours stay the same for everyone, so *revoked* is always red. The claim panel ends with a small "Powered by SunLicense" link. With **Hide SunLicense branding** (Standard), SunLicense's name, logo and that link disappear from these messages. The bot itself is still the SunLicense app in Discord. Messages for your staff (notifications, `/license`, `/stats`) keep SunLicense's look.

Changes reach Discord within 5 minutes. The claim panel is a message posted once, so run `/sunlicense panel` again (and delete the old one) to show a new logo or colour on it.

**Self-service machine reset** lets a customer free one machine slot a day. Their app activates the new machine on its next check. Turn it off per server in the dashboard if your support team handles resets.

## Support tickets and questions

Your buyers can open [support tickets](/guide/support-tickets) and ask your [help center](/guide/help-center) without leaving your server.

* **`/sunlicense tickets staff_role:@Support`**: run it in the channel for the ticket panel. It posts **Open a ticket**. Needs **Manage organization**. To pick the channel, the Discord category tickets open in and the panel's words, deploy it from Tools › Support tickets › ⋯ › **Categories & Discord panel** instead.
* **`/ticket`**: a buyer who has claimed a license fills in a short form, and the ticket gets its **own private channel** (`#ticket-0012`) in the panel's category, seen by the buyer, the role you named and the bot.
* **Messages in the channel** are the ticket's conversation: they show up in the dashboard, and replies from the dashboard, the portal and the AI are posted in the channel. **Close ticket** locks the channel; the team's **Reopen** and **Delete channel** sit on the closed note. A closed ticket asks the buyer to rate the help.
* **`/ask`**: a private answer from your published help center, with links to the pages it comes from.

Give the bot **Manage Channels**. People write in the ticket's channel like in any chat: every message is a reply on the ticket.

## Key drops

```
/drop policy:"Acme Editor · Pro" count:10 title:"Launch week giveaway"
```

Each member presses **Claim a key**, enters their email, and gets a fresh license privately (also saved under `/my-licenses`). One per member; the banner's count and bar update as keys go, and the button turns off when the last one is claimed. Every key is a real license and counts toward your plan's license limit.

## How it looks

Every image uses the dashboard's dark colours, so Discord and the dashboard look like one product. SunLicense ships its own emoji set: line icons, status dots, and one dot per machine slot that turns red when a license uses all its machines.

Charts are rendered as images:

## Self-hosting

The integration is off until the Discord application is configured. In the [Discord Developer Portal](https://discord.com/developers/applications):

1. Create an application. Copy **Application ID** and **Public Key** (General Information) and a **bot token** (Bot → Reset Token). No privileged intents are needed.
2. Put them in `deploy/.env` as `DISCORD_APPLICATION_ID`, `DISCORD_PUBLIC_KEY`, `DISCORD_BOT_TOKEN` and restart `discord-service`. It registers the commands and uploads its emojis on startup.
3. Set **Interactions Endpoint URL** to `https://api.<your domain>/api/v1/discord/interactions`. Discord checks it with a signed request, so do step 2 first.
4. Under **Installation**, enable *Guild Install* (scopes `bot`, `applications.commands`) and *User Install* (`applications.commands`).

If a Cloudflare WAF or Bot Fight Mode sits in front of your API, allow `/api/v1/discord/interactions`.
