# Discord Automation

### Overview

This guide explains how to automate license issuance in SunLicense using the Discord bot. Once a user receives the designated product-purchased role, they can claim a license key for that product without direct contact with you.

### Step 1: Assigning a Product Purchased Role in SunLicense

When creating a product in SunLicense, you can specify a **Product Purchased Discord Role ID**. This role should be given to users upon purchasing the product through your system or any other sales system.

#### If You Are Creating a New Product:

1. Go to the **Products** page in the SunLicense dashboard.
2. Click **Create Product**.
3. Enter all necessary product details.
4. Find the **Product Purchased Role ID** field.
5. Enter the **Discord Role ID** that represents users who have purchased this product.
6. Save the product.

#### If You Already Have an Existing Product:

1. Go to the **Products** page.
2. Click **Manage Products**.
3. Select the product you want to update.
4. Locate the **Product Purchased Role ID** field.
5. Enter or update the **Discord Role ID**.
6. Save the changes.

### Step 2: Assigning the Role to Users

* Ensure that your system (or any other sales platform) grants the **Product Purchased Role** to a user when they buy the product.
* This role acts as proof that the user has purchased the product.

### Step 3: License Claiming with `/get-license` Command

Once a user receives the **Product Purchased Role**, SunLicense will recognize them as a valid purchaser.

#### How Users Can Claim a License:

1. Join your Discord server.
2. Ensure they have the required **Product Purchased Role**.
3. Execute the `/get-license` command in the designated Discord channel.
4. SunLicense will automatically issue a license key for the product.
5. The user will receive their license key immediately.

### Notes

* The **Product Purchased Role** should be granted when a user buys the product.
* Users must have the correct role before executing `/get-license`.
* This automation removes the need for manual license distribution.

### Conclusion

By following this guide, you can streamline the license issuance process, allowing users to claim their licenses effortlessly via Discord. 🚀


---

# Agent Instructions: 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:

```
GET https://docs.sunlicense.hapangama.com/automations/discord-automation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
