> For the complete documentation index, see [llms.txt](https://synclab.gitbook.io/sl-commands/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://synclab.gitbook.io/sl-commands/commands-and-contexts/ping-command.md).

# Ping command example

**Welcome to Commands & Contexts section!**&#x20;

First you must setup you SLCommands:

{% content-ref url="/pages/v9PotbXR4lSdvJRaKcch" %}
[Easy Setup & Options Object](/sl-commands/setup.md)
{% endcontent-ref %}

Then create a "commands" folder where you can create a "ping.js" or "ping.ts" file.

{% hint style="warning" %}
Do not forget: `onExecute` or  `addSubCommand` must be the last functions, so the command is properly registered.
{% endhint %}

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

```javascript
const { ChatInputCommand } = require('sl-commands')

new ChatInputCommand()
  // The command name (required)
  .setName('ping')
  // The command description (required)
  .setDescription('Shows my ping')
  // Only register for the testing servers
  .setTestOnly(true)
  // Executed whenever the command is used
  .onExecute(({ client, interaction }) => {
    // Replying the slash command interaction
    interaction.reply(`API's ping is ${client.ws.ping}`)
  })
```

{% endcode %}
{% endtab %}

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

```typescript
import { ChatInputCommand } from 'sl-commands'

new ChatInputCommand()
  // The command name (required)
  .setName('ping')
  // The command description (required)
  .setDescription('Shows my ping')
  // Only register for the testing servers
  .setTestOnly(true)
  // Executed whenever the command is used
  .onExecute(({ client, interaction }) => {
    // Replying the slash command interaction
    interaction.reply(`API's ping is ${client.ws.ping}`)
  })
```

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