> 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/creating-a-simple-ping-pong-command.md).

# Creating a simple "Ping Pong" Command

At this page, you will learn how to create a simple "Ping Pong" command.

{% hint style="warning" %}
Before creating a command, please make sure you have specified a **commands directory** with the **correct syntax** as shown in the [Setting Up Your Project](/nocli-handler.js/getting-started/setting-up-your-project.md) page.&#x20;
{% endhint %}

### How to create a "Ping Pong" Command

{% tabs %}
{% tab title="JavaScript" %}
**Firstly**, create a file in the commands directory you specified in the **index.js** file, and name it **ping.js**.

![](https://2061993693-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxf3u6ixvplxDFSNlKMyF%2Fuploads%2F1DYvnqjRm9dOJKOMsCr7%2Fimage.png?alt=media\&token=9dcb40ec-93f5-448c-8df2-cbd11f5a57f5)

**Secondly**, paste this code into your **ping.js** file.

{% code title="ping.js" %}

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

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

module.exports = Command;
```

{% endcode %}
{% endtab %}

{% tab title="TypeScript" %}
Firstly, create a file in the commands directory you specified in the **index.ts** file, and name it **ping.ts**.

![](https://2061993693-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxf3u6ixvplxDFSNlKMyF%2Fuploads%2FNoHyRYcOfyk8yw8P5D7B%2Fimage.png?alt=media\&token=96056d60-939d-46f7-b944-47f654ed770a)

**Secondly**, paste this code into your **ping.ts** file.

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

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

export default {
    type: NoCliCommandType.Legacy,
    description: "Ping",
    callback: ({ client, message, args, text }) => {
        return `🏓 Pong! \`${client.ws.ping}ms\``;
    }
} as ICommand;
```

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

{% hint style="info" %}
You may receive a warning from the console that says `No mongoURI provided`. Just ignore that warning since this command doesn't require a database.
{% endhint %}

Once your program starts, try running the ping command:

![](https://2061993693-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fxf3u6ixvplxDFSNlKMyF%2Fuploads%2F6Fb3qfjK6M5IwEZ1g3pp%2Fimage.png?alt=media\&token=85f9f702-3306-4da3-bc16-3c6e1baa2024)

For the default prefix during the nocli-handler.js initialization, if you have set any, please replace "!" with the default prefix you have set.
