# Basic Reaction Logic (1/2)

Heading back up to the `// the reaction logic will be here` comment, lets replace it with a bare-bones function:

([see more about destructing](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment)^)

```javascript
const awaitReactions = async (msg, m, options, filter) => {
    // simplify the use of these options, using destructing^
    const { min, max, page, limit } = options;
    
    m.awaitReactions(filter, { max: 1, time: limit, errors: ['time'] })
    .then(async (collected) => {
        // logic
    }).catch(() => {});
}
```

Heading in to the function, where `// logic` sits, lets pull the reaction from what we collected:

```javascript
const reaction = collected.first();
```

Now we have our reaction, and what we need ready, we can add the scaffolding for reactions, and handle them accordingly:

```javascript
// add this below where we define reaction, but inside the '.then'

if (reaction.emoji.name === '⬅') {
    // a.       
}
else if (reaction.emoji.name === '➡') {
    // b.
}
else if (reaction.emoji.name === '🗑') {
    // c.
}
else {
    // d.
}
```

Now we can move on.


---

# 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/basic-reaction-logic-1-2.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.
