> For the complete documentation index, see [llms.txt](https://tribui141108.gitbook.io/nocli-handler.js/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tribui141108.gitbook.io/nocli-handler.js/guides/commands/enabling-slash-commands.md).

# Enabling Slash Commands

Slash commands are commands registered from a bot to Discord with the "/" prefix for those who are not used to legacy (or text) commands.

### Using `slash` option

`type` is a command option to define what the command can be used for. The only options available are:

* [x] Legacy Commands (`LEGACY`)
* [x] Slash Commands (`SLASH`)
* [x] or both (`BOTH`)

{% hint style="info" %}
This option is not required, so when you do not specify this option, the command will be a legacy command. So ¯\\\_(ツ)\_/¯
{% endhint %}

On the [first](/nocli-handler.js/guides/commands/creating-a-simple-ping-pong-command.md) page of the Commands Guide, we learned how to create our very own ping command (which is a legacy command). So let's use that as an example of creating a Slash Command.

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

```javascript
const { NoCliCommandType } = require("nocli-handler.js");

/**
 * @type {import("nocli-handler.js").ICommand}
 */
const Command = {
    description: "Checks client latency",
    type: NoCliCommandType.Both, // <-- Set the command type here (optional)
    callback: ({ client, message, args, text }) => {
        return `🏓 Pong! \`${client.ws.ping}ms\``
    }
}

module.exports = Command;
```

{% endcode %}
{% endtab %}

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

```typescript
import { ICommand, NoCliCommandType } from "nocli-handler.js";

export default {
    description: "Ping",
    type: NoCliCommandType.Both, // <-- Set the command type here
    callback: ({ client, message, args, text }) => {
        return `🏓 Pong! \`${client.ws.ping}ms\``;
    }
} as ICommand;
```

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

Once done, run the program, and let's try running the "ping" command. Her&#x65;**'**&#x73; what it will appear:

**Legacy Command:**

![](https://2061993693-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxf3u6ixvplxDFSNlKMyF%2Fuploads%2FIekz540vlyHoHOJUx1My%2Fimage.png?alt=media\&token=13ae7fb5-17ee-47df-bef6-6814c714d3e6)

**Slash Command:**

![](https://2061993693-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxf3u6ixvplxDFSNlKMyF%2Fuploads%2FlttGIBslExOslQlqdJD1%2Fimage.png?alt=media\&token=28d0cbdf-1918-4b1b-bcdb-3e3b1838dc22)
