> For the complete documentation index, see [llms.txt](https://whitepaper.aitech.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://whitepaper.aitech.io/agentforge/tools/discord.md).

# discord

[Discord](https://discord.com/) is a communication platform that supports text, voice, and video interactions within servers and communities. Discord bots extend the platform’s capabilities by automating actions, responding to messages, and integrating with external systems.

With a Discord bot, you can:

* **Send messages**: Post automated updates or notifications into channels.
* **Read messages**: Retrieve recent chat messages for analysis or display.
* **Access server info**: Retrieve metadata such as server name, member count, and roles.
* **Access user info**: Fetch specific user information by their unique Discord ID.

In Agent Forge, the Discord integration allows your agents to interact with servers programmatically, automate notifications, and connect workflows with Discord communities.

### Setup Instructions

Follow these steps carefully to create a Discord bot, get your IDs, and connect everything properly.

#### Create a Discord Application and Bot

{% stepper %}
{% step %}
Go to the [Discord Developer Portal](https://discord.com/developers/applications).
{% endstep %}

{% step %}
Click **“New Application”** → give it a name and click **Create**.
{% endstep %}

{% step %}
In the left sidebar, click **“Bot”** → **“Add Bot”** → **“Yes, do it!”**
{% endstep %}

{% step %}
Under **TOKEN**, click **“Reset Token”** → copy the **Bot Token** and store it safely.

Example placeholder:

```
DISCORD_BOT_TOKEN=your_bot_token_here
```

{% endstep %}

{% step %}
Scroll down to **Privileged Gateway Intents** and enable:

* **Message Content Intent**
* **Server Members Intent** (if you want user data)
* **Presence Intent** (optional but useful for activity info)
  {% endstep %}

{% step %}
Click **Save Changes**.
{% endstep %}
{% endstepper %}

#### Invite the Bot to a Discord Server

{% stepper %}
{% step %}
In the **OAuth2 → URL Generator** section:

* Under **SCOPES**, check:
  * `bot`
  * `applications.commands`
* Under **BOT PERMISSIONS**, select:
  * `Send Messages`
  * `Read Message History`
  * `View Channels`
  * `Manage Messages` (optional)
    {% endstep %}

{% step %}
Copy the generated OAuth2 URL and open it in your browser.
{% endstep %}

{% step %}
Select a **server** you manage → click **Authorize** → complete CAPTCHA.
{% endstep %}

{% step %}
Your bot will now appear in the server’s member list.
{% endstep %}
{% endstepper %}

#### 3️⃣ Get Required IDs

You’ll need several Discord IDs for API access.

**Enable Developer Mode (one-time)**

{% stepper %}
{% step %}
Open Discord → click the **⚙️ Settings** icon → **Advanced**.
{% endstep %}

{% step %}
Turn on **Developer Mode**.
{% endstep %}
{% endstepper %}

Now you can right-click items to copy their unique IDs.

**Get the Server ID (Guild ID)**

* Right-click your **server icon** in Discord → **Copy Server ID**. : `DISCORD_SERVER_ID=123456789012345678`

**Get the Channel ID**

* Right-click the **channel name** → **Copy Channel ID**. : `DISCORD_CHANNEL_ID=123*********`

**Get a User ID**

* Right-click the **user’s profile picture or name** → **Copy User ID**. : `DISCORD_USER_ID=12345********`

### Tools

#### `discord_send_message`

Send a message to a Discord channel

**Input**

| Parameter   | Type   | Required | Description                                   |
| ----------- | ------ | -------- | --------------------------------------------- |
| `botToken`  | string | Yes      | The bot token for authentication              |
| `channelId` | string | Yes      | The Discord channel ID to send the message to |
| `content`   | string | No       | The text content of the message               |
| `serverId`  | string | Yes      | The Discord server ID (guild ID)              |

**Output**

| Parameter | Type   | Description     |
| --------- | ------ | --------------- |
| `message` | string | Message content |
| `data`    | any    | Response data   |

#### `discord_get_messages`

Retrieve messages from a Discord channel

**Input**

| Parameter   | Type   | Required | Description                                                    |
| ----------- | ------ | -------- | -------------------------------------------------------------- |
| `botToken`  | string | Yes      | The bot token for authentication                               |
| `channelId` | string | Yes      | The Discord channel ID to retrieve messages from               |
| `limit`     | number | No       | Maximum number of messages to retrieve (default: 10, max: 100) |

**Output**

| Parameter | Type   | Description     |
| --------- | ------ | --------------- |
| `message` | string | Message content |
| `data`    | any    | Response data   |

#### `discord_get_server`

Retrieve information about a Discord server (guild)

**Input**

| Parameter  | Type   | Required | Description                      |
| ---------- | ------ | -------- | -------------------------------- |
| `botToken` | string | Yes      | The bot token for authentication |
| `serverId` | string | Yes      | The Discord server ID (guild ID) |

**Output**

| Parameter | Type   | Description     |
| --------- | ------ | --------------- |
| `message` | string | Message content |
| `data`    | any    | Response data   |

#### `discord_get_user`

Retrieve information about a Discord user

**Input**

| Parameter  | Type   | Required | Description                          |
| ---------- | ------ | -------- | ------------------------------------ |
| `botToken` | string | Yes      | Discord bot token for authentication |
| `userId`   | string | Yes      | The Discord user ID                  |

**Output**

| Parameter | Type   | Description     |
| --------- | ------ | --------------- |
| `message` | string | Message content |
| `data`    | any    | Response data   |

### Notes

* Category: `tools`
* Type: `discord`
