# Callback System

The callback system aims to be similar to the InteractionHandler but in a more Low Code manner, requiring less coding.

It is important to know that if the bot is restarted, the callback provided in the component may no longer be valid until the component is generated again, so it may not be useful for all situations.

Exemple:

```javascript
import { ApplicationCommandType } from "discord.js";
import { CreateRow, CreateButton, InteractionHandler} from "ease-discord-js";

export default {
    name: "test",
    description: "command to test the library",
    type: ApplicationCommandType.ChatInput,

    run: async(client, interaction) => {
       return interaction.reply({content: "Hello World!", components: [
            new CreateRow([
                new CreateButton({label: "Primary", style: "Primary", onClick: (client, interaction) => clickHandler(client, interaction)}),
            ])
        ]});
    }
}

const clickHandler = (client, interaction) => {
    interaction.reply({content: "Button Clicked! ( using callback ) ", ephemeral: true});
}
```

Result:

<figure><img src="https://cdn.discordapp.com/attachments/1225958170732793898/1238313109404520448/image.png?ex=663f7d34&#x26;is=663e2bb4&#x26;hm=c6e5fe7095760531e2eb566eb74f7d661be6eef0747a105968a6eea942d3efc6&#x26;" alt=""><figcaption></figcaption></figure>

You can notice that the only change we have in the button is that the callback attribute receives a function. This function will be called when the button is clicked, and we can manipulate the parameters of this function as it is called.


---

# 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://camposcodes.gitbook.io/easediscordjs/tools/callback-system.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.
