> For the complete documentation index, see [llms.txt](https://docs.wornoffkeys.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wornoffkeys.com/commands/inferred-slash-command-arguments.md).

# Inferred slash command arguments

Slash commands handle arguments differently, however WOKCommands will allow you to specify your slash command arguments in the same way as normal commands.

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

```javascript
const { CommandType, CommandObject, CommandUsage } = require("wokcommands");

module.exports = {
  description: "Adds numbers together",

  // Only register a slash command, not a legacy command
  type: CommandType.SLASH,

  minArgs: 2,
  maxArgs: 2,
  expectedArgs: "<num1> <num2>",

  callback: ({ args }) => {
    const sum = args.reduce((acc, cur) => {
      return acc + Number(cur);
    }, 0);

    return `The sum is ${sum}`;
  },
};
```

{% endcode %}
{% endtab %}

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

```typescript
import { CommandType, CommandObject, CommandUsage } from "wokcommands";

export default {
  description: "Adds numbers together",

  // Only register a slash command, not a legacy command
  type: CommandType.SLASH,

  minArgs: 2,
  maxArgs: 2,
  expectedArgs: "<num1> <num2>",

  callback: (options: CommandUsage) => {
    const { args } = options;

    const sum = args.reduce((acc, cur) => {
      return acc + Number(cur);
    }, 0);

    return `The sum is ${sum}`;
  },
} as CommandObject
```

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

Behind the scenes WOKCommands will create an array of [options](https://discord.js.org/#/docs/discord.js/main/typedef/ApplicationCommandOption) for your slash commands. As  you will see in the next section you can always customize these options if need be.

{% hint style="warning" %}
When using inferred arguments with slash commands, it's very important that you provide `minArgs` and `expectedArgs` properties.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/commands/inferred-slash-command-arguments.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.
