# Command

{% hint style="info" %}
From now on, I'm omitting the surrounding code, and just providing the current code.
{% endhint %}

Lets start right here, at the help command comment..

```javascript
    if (command == 'help') {
        // our help command will be here
    }
```

Remove the comment, as we'll start writing a few things here now. First, lets specify an object with some settings for the reaction help:

```javascript
const options = {
    limit: 15 * 1000,
    min: 1,
    max: 2, // there will be 2 pages
    page: 1
}
```

Let me explain these..

* `limit` is how long you want to wait for a reaction before timing out completely. Here, we've set it to 15 seconds, a reasonable time.
* `min` is the minimum page, aka. the lowest you can go.
* `max` is the maximum page, aka. the highest you can go, usually the last page.
  * Both min and max are used to set the limits for the user, so errors won't occur.
* `page` is the page to start the help on, and should probably be left as `1`.

Now, we can add some basic code to send an embed, and add the reactions:

```javascript
// don't worry, we'll define pages next
const m = await msg.channel.send({ embed: pages[options.page] });

await m.react('⬅');
await m.react('➡');
await m.react('🗑');
```

Here, we're sending the first page, and adding the back, forward and delete reactions (those are, in Discord, `:arrow_left:`, `:arrow_right:` and `:wastebasket:)`.

For watchful users, we can define pages now. For simplicity, we'll just use an object. Go to where we made the `// pages` comment, and replace it with this code:

```javascript
const pages = {
    1: { title: ':one:', description: 'This is page one!' }, 
    2: { title: ':two:', description: 'This is page two!' }
}
```

{% hint style="info" %}
These are embed objects, we're using them so we don't have to use the more complicated (in this situation) embed builder.
{% endhint %}

Now, you have pages, and these will be sent on request.

Finally, to finish the command, add this little bit of code (we'll be coding next) to start listening for reactions:

```javascript
const filter = (reaction, user) => {
    return ['⬅', '➡', '🗑'].includes(reaction.emoji.name) && user.id == msg.author.id;
};

awaitReactions(msg, m, options, filter);
```

The filter may look complicated, but all it does is makes sure the reaction received is one we want, and that the person that reacts is who used the help command.


---

# 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://tonybo981.gitbook.io/reaction-help-guide/stable/command.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.
