# Custom slash command arguments

Sometimes you may want to pass in your own [options](https://discord.js.org/#/docs/discord.js/main/typedef/ApplicationCommandOption) objects to your slash command. This gives you more control over the exact details of your arguments.

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

```javascript
const { ApplicationCommandOptionType } = require("discord.js");
const { CommandType } = require("wokcommands");

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

  // Create a legacy and slash command
  type: CommandType.BOTH,

  // An array of
  // https://discord.js.org/#/docs/discord.js/main/typedef/ApplicationCommandOption
  options: [
    {
      name: "num1",
      description: "The first number",
      type: ApplicationCommandOptionType.Number,
      required: true,
    },
    {
      name: "num2",
      description: "The second number",
      type: ApplicationCommandOptionType.Number,
      required: true,
    },
  ],

  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 { ApplicationCommandOptionType } from "discord.js";
import { CommandType, CommandObject, CommandUsage } from "wokcommands";

export default {
  description: "Adds numbers together",

  // Create a legacy and slash command
  type: CommandType.BOTH,

  // An array of
  // https://discord.js.org/#/docs/discord.js/main/typedef/ApplicationCommandOption
  options: [
    {
      name: "num1",
      description: "The first number",
      type: ApplicationCommandOptionType.Number,
      required: true,
    },
    {
      name: "num2",
      description: "The second number",
      type: ApplicationCommandOptionType.Number,
      required: true,
    },
  ],

  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 %}

The options array in this code snippet is similar to what WOKCommands will auto generate from the code in [Inferred slash command arguments](/commands/inferred-slash-command-arguments.md).


---

# 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/commands/custom-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.
