# CommandContext

The CommandContext is a class used in the  `run` method of the commands to include all the properties you need, it also includes a lot of getters and useful methods to shorten your code.

```javascript
// from a command
async run(ctx) {
    ctx.send(`${ctx.commandName} executed by ${ctx.user} in ${ctx.channel} !`);
    ctx.react('👍');
    ctx.send('I will now destroy your message in 10 seconds...');
    ctx.deleteMessage(10000);
}
```

## [SubCommandContext](https://advanced-command-handler.github.io/docs/classes/SubCommandContext.html)

From within [SubCommands](/advanced-command-handler/concepts/commands/subcommands.md) the `ctx` argument in the callback is an instance of the `SubCommandContext` class which includes some other fields related to the SubCommand itself.

## [Documentation](https://advanced-command-handler.github.io/docs/classes/CommandContext.html)


---

# 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://ayfri.gitbook.io/advanced-command-handler/concepts/commands/context.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.
