# Guard

Gives access to individual commands only to admins.

Initial setup:

* Install Library
* Сreate `/setup` command:

```javascript
Libs.Guard.setup();
```

You will have such admin panel:

![](https://3310729168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LVh0yg9olT-QWqi3AYt%2Fuploads%2FeBZrmbnNtGSl1WEe15P2%2Fimage.png?alt=media\&token=4d2a709d-18cc-4eff-88b7-672172b4497b)

* Create the @ command or add to an existing one the following code (at the very beginning):

```
if (!Libs.Guard.verifyAccess()) return;
```

Add the commands you want to restrict access to to the "admins" folder (by default).

You can add/remove admins, change the folder for admin commands and add a command for unauthorized access attempts in the admin panel:&#x20;

`App > Bot > Admin Panels > Guard.`

### Checking access

{% hint style="success" %}
Just put all your admin commands in one folder.

The check will be automatic.
{% endhint %}

For manuall checking mode use:

```javascript
if (Libs.Guard.isAdmin(user.id)){
   // admin
}else{
   // not admin
}
```


---

# 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://help.bots.business/libs/guard.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.
