# How to make a Discord bot

## Creating a Bot

**Step 1.** Create an application ([follow the link](https://discord.com/developers/applications)).

**Step 2.** Add a bot (click on the "**Add Bot" button**).

<div data-with-frame="true"><figure><img src="/files/ofQQzDZHM4UUhdpaecJp" alt=""><figcaption></figcaption></figure></div>

**Step 2.1.** In the **Installation** section, select **Install Link → None**.

<div data-with-frame="true"><figure><img src="/files/0htI0MDEe26AJdBXoyBk" alt=""><figcaption></figcaption></figure></div>

**Step 2.2.** In the **Bot** section, disable **Public Bot**, then enable the following **Intents**:

* **Message Content Intent**
* **Server Members Intent**

You may also enable **Presence Intent** for future use.

<div data-with-frame="true"><figure><img src="/files/wLxeKoni97rPpkIcRLFB" alt=""><figcaption></figcaption></figure></div>

<div data-with-frame="true"><figure><img src="/files/x9GdLJ6UX5s9iBweHa0x" alt=""><figcaption></figcaption></figure></div>

**Step 3.** Get the token (**Reset Token**).

**Step 4.** Add the bot to the server:

* Go to **OAuth2 → URL Generator**.
* In **Scopes**, select **bot**.
* In **Bot Permissions**, choose **Send Messages**, **Read Message History**, and any other required permissions.

Then open the generated link, select the server where you want to add the bot, and confirm the authorization.

<div data-with-frame="true"><figure><img src="/files/nsHyYJGevKix1nJy1Qmh" alt=""><figcaption></figcaption></figure></div>

<div data-with-frame="true"><figure><img src="/files/MgctRvUdVto4JYnoKwg1" alt=""><figcaption></figcaption></figure></div>

To obtain the full webhook from Discord, simply assign any value to the **save\_webhook** variable.

If the variable is set, the webhook will be saved to **discord\_webhook**.

## Connecting the Discord Bot in MaviBot

Now go to the **“Messengers”** section in your project in **MaviBot**:

<div data-with-frame="true"><figure><img src="/files/zXENnMOCjGqysgpwsE9H" alt=""><figcaption></figcaption></figure></div>

Then paste the token copied from **Discord**.

<div data-with-frame="true"><figure><img src="/files/hziacZpbrpiPSeMRGjPf" alt=""><figcaption></figcaption></figure></div>

Click the **Done** button.

## Calculator Functions

### Reply to a Message

discord\_reply\_to\_message(message\_id, text) - This function is used to **reply to a message**.

| Parameters                                            | Description                                           |
| ----------------------------------------------------- | ----------------------------------------------------- |
| <mark style="color:$danger;">**!**</mark> message\_id | The **ID of the message** to which you want to reply. |
| <mark style="color:$danger;">**!**</mark> text        | The **text of the reply message**.                    |

### Delete a Message

discord\_delete\_message(message\_id) - This function is used to **delete a message.**&#x20;

| Parameters                                            | Description                          |
| ----------------------------------------------------- | ------------------------------------ |
| <mark style="color:$danger;">**!**</mark> message\_id | The **ID of the message** to delete. |

### Edit a Message

discord\_edit\_message(message\_id, text) - This function is used to **edit a message**.

| Parameters                                            | Description                        |
| ----------------------------------------------------- | ---------------------------------- |
| <mark style="color:$danger;">**!**</mark> message\_id | The **ID of the message** to edit. |
| <mark style="color:$danger;">**!**</mark> text        | The **new text of the message**.   |

### Pin a Message

discord\_pin\_message(message\_id) - This function is used to **pin a message.**

| Parameters                                            | Description                       |
| ----------------------------------------------------- | --------------------------------- |
| <mark style="color:$danger;">**!**</mark> message\_id | The **ID of the message** to pin. |

### Unpin a message

discord\_unpin\_message(message\_id) - This function is used to **unpin a message.**

| Parameters                                            | Description                         |
| ----------------------------------------------------- | ----------------------------------- |
| <mark style="color:$danger;">**!**</mark> message\_id | The **ID of the message** to unpin. |

### Send a reaction to a message

discord\_send\_reaction(message\_id, reaction) - This function is used to **send a reaction to a message.**

| Parameters                                            | Description                                                                                                                                                                          |
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <mark style="color:$danger;">**!**</mark> message\_id | The **ID of the message** to send a reaction to.                                                                                                                                     |
| <mark style="color:$danger;">**!**</mark> reaction    | The **reaction to send**. You can provide a single emoji (e.g., ❤️) or the ID of a custom emoji on the server. Information on how to get the ID of a custom emoji is provided below. |

### Remove a reaction from a message in a channel

discord\_delete\_reaction(message\_id, reaction, user\_id) - This function is used to **remove a reaction from a message in a channel.**

| Parameters                                            | Description                                                                                                                                                                            |
| ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <mark style="color:$danger;">**!**</mark> message\_id | The **ID of the message** from which to remove the reaction.                                                                                                                           |
| <mark style="color:$danger;">**!**</mark> reaction    | The **reaction to remove**. You can provide a single emoji (e.g., ❤️) or the ID of a custom emoji on the server. Information on how to get the ID of a custom emoji is provided below. |
| user\_id                                              | The **ID of the user** whose reaction you want to remove. This parameter is optional if you want to remove the reaction from the current bot.                                          |

## Callbacks

When a user sends a reaction, a callback is received in the chat in the following format:

new\_like ❤️ uid413984787162726410

<div data-with-frame="true"><figure><img src="/files/6KSONU0SR5JrEdTmaHg7" alt="" width="563"><figcaption></figcaption></figure></div>

Where `uid413984787162726410` is the **ID of the user** who sent the reaction.

## How to get the ID of a custom emoji

If you send a custom reaction to a message in a Discord channel, a callback will be received in the following format:

new\_like beer:1479419477396291696 uid413984787162726410

<div data-with-frame="true"><figure><img src="/files/zmMbV0s9maszr9n0dvd9" alt="" width="563"><figcaption></figcaption></figure></div>

Where `beer:1479419477396291696` is the **ID of the reaction**. You can copy it for use in reaction-related functions.

## How to get the Message ID

You can get the client’s message ID from the webhook if **save\_webhook** is enabled. Example:

`data = discord_webhook["data"]`\
`msg_id = data["id"]`\
`result = discord_reply_to_message(msg_id, "This is a reply to a message")`


---

# 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.mavibot.ai/chatbot/messengers/discord/chatbot.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.
