Skip to content

Commit 28f8fac

Browse files
committed
document after function
1 parent 91f16e8 commit 28f8fac

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,40 @@
11
---
22
title: after function
33
---
4+
5+
The `after` function allows you to execute a callback after a command
6+
has been executed. This is useful for performing actions that should
7+
occur after the command has completed, such as logging or cleanup
8+
tasks.
9+
10+
## Usage
11+
12+
```ts title="src/app/commands/ping.ts"
13+
import {
14+
type CommandData,
15+
type ChatInputCommand,
16+
after,
17+
} from 'commandkit';
18+
19+
export const command: CommandData = {};
20+
21+
export const chatInput: ChatInputCommand = async (ctx) => {
22+
after(() => {
23+
// This code will be executed after the command has been executed
24+
console.log('Command has been executed');
25+
});
26+
27+
await ctx.interaction.reply({
28+
content: 'Hello World',
29+
ephemeral: true,
30+
});
31+
};
32+
```
33+
34+
:::info
35+
36+
The `after` function is guaranteed to be called after the command has
37+
been executed, regardless of whether the command was successful or
38+
not.
39+
40+
:::

0 commit comments

Comments
 (0)