> 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

{% 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**.

![](/files/oBEr4C0zBq79zfh85MNQ)

**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**.

![](/files/hecqSEjgONh1heGdt0hB)

**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:

![](/files/igIHn0zm0Ylnj4Ile5Cb)

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