Skip to content

Commit

Permalink
docs: update create task function type (#623)
Browse files Browse the repository at this point in the history
  • Loading branch information
Williams Bussat authored Sep 19, 2024
1 parent e6fdc84 commit f730be1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/scheduled-tasks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ import { container } from '@sapphire/framework';

export class MyAwesomeService {
public createAwesomeTask() {
container.tasks.create('name', { id: '123' }, 2000);
const payload = { awesome: true };
container.tasks.create({ name: 'awesome', payload }, 2000);
}
}
```
Expand All @@ -95,7 +96,8 @@ export class MuteCommand extends Command {

public async run(message: Message) {
// create a task to unmute the user in 1 minute
this.container.tasks.create('unmute', { authorId: message.author.id }, 60_000);
const payload = { authorId: message.author.id };
this.container.tasks.create({ name: 'unmute', payload }, 60_000);
}
}
```
Expand Down Expand Up @@ -131,14 +133,15 @@ declare module '@sapphire/plugin-scheduled-tasks' {
##### Using Manual Tasks

```typescript
container.tasks.create('manual', payload, 5000);
const payload = { awesome: true };
container.tasks.create({ name: 'manual', payload }, 5000);
```

#### Pattern Task Example

Pattern jobs are currently only supported by the Redis strategy.

##### Creating the Piece:
##### Creating the Piece

```typescript
import { ScheduledTask } from '@sapphire/plugin-scheduled-tasks';
Expand Down

0 comments on commit f730be1

Please sign in to comment.