> 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/running-events-inside-a-command.md).

# Running Events inside a Command

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

```javascript
/**
 * @type {import("nocli-handler.js").ICommand}
 */
const Command = {
    init: (client) => {
        // Create events here
    },
    type: "BOTH",
    description: "Checks client latency",
    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 } from "nocli-handler.js";

export default {
    init: (client) => {
        // Create events here
    },
    description: "Checks client latency",
    type: "BOTH",
    callback: ({ client, message, args, text }) => {
        return `🏓 Pong! \`${client.ws.ping}ms\``;
    }
} as ICommand;
```

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

After creating events using `init` function, once the program starts, this function will automatically be called **once**.
