> For the complete documentation index, see [llms.txt](https://azlicense.gitbook.io/azlicense-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://azlicense.gitbook.io/azlicense-docs/bot.md).

# BOT

## Setup

1. Create a Discord application at <https://discord.com/developers/applications>
2. Go to Bot section → Reset Token → Copy
3. Set `BOT_TOKEN` in `.env`
4. Invite the bot with `applications.commands` scope via OAuth2 URL Generator
5. Run `python run.py` or `python -m bot.main`

## Permission Levels

| Level        | Config                        | Access                          |
| ------------ | ----------------------------- | ------------------------------- |
| **Admin**    | `ADMIN_DISCORD_IDS` in `.env` | Full access — all commands      |
| **Support**  | `SUPPORT_ROLE_ID` in `.env`   | View-only — info, list, servers |
| **Everyone** | —                             | `/stats` only                   |

## Commands

### Product Management

| Command                                                           | Access   | Description         |
| ----------------------------------------------------------------- | -------- | ------------------- |
| `/product create <name> [description] [duration_days]`            | Admin    | Create a product    |
| `/product edit <product_id> [name] [description] [duration_days]` | Admin    | Edit a product      |
| `/product delete <product_id>`                                    | Admin    | Delete a product    |
| `/product list`                                                   | Support+ | List all products   |
| `/product info <product_id>`                                      | Support+ | Get product details |

### License Management

| Command                                                                                 | Access   | Description                                          |
| --------------------------------------------------------------------------------------- | -------- | ---------------------------------------------------- |
| `/license create <customer> <product> [expiration_type] [duration_days] [server_limit]` | Admin    | Create a license (auto-assigns role, syncs customer) |
| `/license suspend <license_key>`                                                        | Admin    | Suspend a license                                    |
| `/license unsuspend <license_key>`                                                      | Admin    | Re-activate a suspended license                      |
| `/license delete <license_key>`                                                         | Admin    | Delete a license                                     |
| `/license info <license_key>`                                                           | Support+ | Get license details with server list                 |
| `/license list`                                                                         | Support+ | List all licenses (last 25)                          |
| `/license export`                                                                       | Admin    | Export all licenses as CSV                           |
| `/license servers <license_key>`                                                        | Support+ | List servers bound to a license                      |
| `/license remove-server <license_key> <server_uuid>`                                    | Admin    | Remove a bound server                                |
| `/license clear-servers <license_key>`                                                  | Admin    | Remove all servers from a license                    |
| `/license server-limit <license_key> <limit>`                                           | Admin    | Change server limit (1–100)                          |

### Bot Setup

| Command           | Access | Description                           |
| ----------------- | ------ | ------------------------------------- |
| `/setup avatar`   | Admin  | Set bot avatar from `assets/logo.png` |
| `/setup username` | Admin  | Change bot username to **AzLicense**  |

### Statistics & Audit

| Command          | Access   | Description                            |
| ---------------- | -------- | -------------------------------------- |
| `/stats`         | Everyone | View system statistics                 |
| `/audit [limit]` | Admin    | View recent audit log entries (max 50) |

## Configuration (.env)

| Variable            | Description                                                    |
| ------------------- | -------------------------------------------------------------- |
| `BOT_TOKEN`         | Discord bot token                                              |
| `ADMIN_DISCORD_IDS` | Comma-separated Discord user IDs (full access)                 |
| `SUPPORT_ROLE_ID`   | Comma-separated role IDs (view-only access)                    |
| `LICENSE_ROLE_ID`   | Role ID auto-assigned to customers on license creation         |
| `API_BASE_URL`      | Base URL of the license API (default: `http://localhost:8000`) |

## Rate Limiting

Certain API routes and bot commands are rate-limited. Admins (`ADMIN_DISCORD_IDS`) are exempt from all rate limits.

## Bio / About Me

Discord does not expose an API for bots to set their "About Me" field. Set it manually in the [Discord Developer Portal](https://discord.com/developers/applications) under your app → Bot → Description.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://azlicense.gitbook.io/azlicense-docs/bot.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
