Skip to content

Commit 7971b42

Browse files
authored
docs: fix tasks api example
1 parent acaf1e0 commit 7971b42

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

packages/tasks/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,12 @@ export default async function refreshExchangeRate(ctx: TaskContext) {
6969

7070
## Dynamic Tasks
7171

72-
Dynamic tasks are created at runtime and can be scheduled to run after a specified duration. They can also be cancelled or invoked manually. To create a dynamic task, use the `createTask` method from the `ctx` object.
72+
Dynamic tasks are created at runtime and can be scheduled to run after a specified duration. They can also be cancelled or invoked manually. To create a dynamic task, use the `tasks.create` method from the `ctx` object.
73+
74+
### Defining a task
7375

7476
```ts
75-
// app/commands/unmute.ts
77+
// app/tasks/unmute.ts
7678
import type { TaskContext, TaskConfig } from '@commandkit/tasks';
7779

7880
export interface UnmuteTaskData {
@@ -97,6 +99,7 @@ export default async function unmute(ctx: TaskContext<UnmuteTaskData>) {
9799
Then, you can create a dynamic task in your command:
98100

99101
```ts
102+
// app/commands/mute.ts
100103
import type { CommandData, SlashCommand } from 'commandkit';
101104
import { ApplicationCommandOptionType } from 'discord.js';
102105

@@ -146,4 +149,4 @@ await ctx.tasks.update(task.id, {
146149
data: { guildId: ctx.guildId, userId: userToMute.id },
147150
duration: '2d',
148151
});
149-
```
152+
```

0 commit comments

Comments
 (0)