# Slash commands

![](/files/iIPgxnqaktaNAp8XZG6X)

## Creating commands

{% hint style="info" %}
**Reminder:** Check the [Detritus Documentation](https://detritusjs.com/classes/interaction_command.interactioncommand) for more advanced settings.
{% endhint %}

A finished command looks like this:

```typescript
import { Interaction } from 'detritus-client'
import { BaseSlashCommand } from '../base'

export default class PingCommand extends BaseSlashCommand {
  constructor () {
    super({
      description: 'Ping',
      name: 'ping'
    })
  }

  async run (context: Interaction.InteractionContext): Promise<void> {
    await context.editOrRespond(context, 'Pong!')
  }
}

```

There are a few things to note with regard to how commands are constructed:

* All commands are new classes that extend a base class, in this example the command is a plain slash command.
* The resulting command is exported as the default export.
* The constructor with a super call is used to set properties of the class instead of directly assigning them, this avoids incompatibilities with Detritus.

## In practice

When restarting WildBeast, your newly created command will automatically be registered as a global command, and will be available within a few hours.

Rather want a guild-based command instead of a global one? Add guild IDs to the constructor of your command:

```typescript
constructor () {
  super({
    description: 'Ping',
    name: 'ping',
    guildIds: ['110462143152803840']
  })
}
```

## What's next?

There are more things you can do with commands, like adding options, creating subcommands, and adding buttons and select menus.

{% content-ref url="/pages/01qlimUVFDJsFgeQj8uU" %}
[Subcommands](/fundamentals/commands/slash-commands/subcommands.md)
{% endcontent-ref %}

{% content-ref url="/pages/AeFUMVhrJ4rrZNnZwYHV" %}
[Options](/fundamentals/commands/slash-commands/options.md)
{% endcontent-ref %}

{% content-ref url="/pages/v8Bau9AiNO19svzlkLIs" %}
[Buttons](/fundamentals/commands/slash-commands/buttons.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wildbeast.guide/fundamentals/commands/slash-commands.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
