# Validation setup

{% embed url="<https://youtu.be/_67r4wq23BA?t=571>" %}

There are two types of validations:

* Runtime validations
  * Ran against a command when it is used
  * Should return a true or false for if the command should be ran
  * You must provide any error messages if need be
  * Arguments:
    * command: Command
    * usage: CommandUsage
    * prefix: string
* Syntax validations
  * Ran against every command when your bot starts up
  * Should throw an error if the syntax for your command is wrong
  * Arguments:
    * command: Command

Here is an example of setting up your validations in your main file:

{% tabs %}
{% tab title="JavaScript" %}
{% code title="index.js" %}

```javascript
const { Client, IntentsBitField, Partials } = require("discord.js");
const path = require("path");
const WOK = require("wokcommands");
require("dotenv/config");

const client = new Client({
  intents: [
    IntentsBitField.Flags.Guilds,
    IntentsBitField.Flags.GuildMessages,
    IntentsBitField.Flags.DirectMessages,
    IntentsBitField.Flags.MessageContent,
  ],
  partials: [Partials.Channel],
});

client.on("ready", () => {
  console.log("The bot is ready");

  new WOK({
    client,
    mongoUri: process.env.MONGO_URI || "",
    commandsDir: path.join(__dirname, "commands"),
    validations: {
      // Where your runtime validation folder is
      runtime: path.join(__dirname, "validations", "runtime"),
      // Where your syntax validation folder is
      syntax: path.join(__dirname, "validations", "syntax"),
    },
  });
});

client.login(process.env.TOKEN);
```

{% endcode %}
{% endtab %}

{% tab title="TypeScript" %}
{% code title="index.ts" %}

```typescript
import { Client, IntentsBitField, Partials } from "discord.js";
import path from "path";
import WOK from "wokcommands";
require("dotenv/config");

const client = new Client({
  intents: [
    IntentsBitField.Flags.Guilds,
    IntentsBitField.Flags.GuildMessages,
    IntentsBitField.Flags.DirectMessages,
    IntentsBitField.Flags.MessageContent,
  ],
  partials: [Partials.Channel],
});

client.on("ready", () => {
  console.log("The bot is ready");

  new WOK({
    client,
    mongoUri: process.env.MONGO_URI || "",
    commandsDir: path.join(__dirname, "commands"),
    validations: {
      // Where your runtime validation folder is
      runtime: path.join(__dirname, "validations", "runtime"),
      // Where your syntax validation folder is
      syntax: path.join(__dirname, "validations", "syntax"),
    },
  });
});

client.login(process.env.TOKEN);
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# 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.wornoffkeys.com/validations/validation-setup.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.
