Manual Scheduled Task not found

I try to manually schedule a task
const payload = { awesome: true };
await container.tasks.create({ name: 'rememberMe', payload }, 5000);
const payload = { awesome: true };
await container.tasks.create({ name: 'rememberMe', payload }, 5000);
My Task Class in the scheduled-tasks folder
import { ScheduledTask } from '@sapphire/plugin-scheduled-tasks';

export class RememberTask extends ScheduledTask {
public async run (payload: unknown) {
this.container.logger.info("i ran", payload);
}
}

declare module '@sapphire/plugin-scheduled-tasks' {
interface ScheduledTasks {
rememberMe: never;
}
}
import { ScheduledTask } from '@sapphire/plugin-scheduled-tasks';

export class RememberTask extends ScheduledTask {
public async run (payload: unknown) {
this.container.logger.info("i ran", payload);
}
}

declare module '@sapphire/plugin-scheduled-tasks' {
interface ScheduledTasks {
rememberMe: never;
}
}
I get this error [ScheduledTaskPlugin] There was no task found for "rememberMe" What am I doing wrong?
Solution:
Then the name is RememberTask. By default sapphire will use the file name as the name of the piece. Either you have to specify a different name in the constructor or rename the file. The module augmentation that you do at the bottom is typescript only, and doesn't affect runtime.
Jump to solution
4 Replies
Favna
Favna3mo ago
What's the name of the file?
ShowCast
ShowCastOP3mo ago
RememberTask.ts
Solution
Favna
Favna3mo ago
Then the name is RememberTask. By default sapphire will use the file name as the name of the piece. Either you have to specify a different name in the constructor or rename the file. The module augmentation that you do at the bottom is typescript only, and doesn't affect runtime.
ShowCast
ShowCastOP3mo ago
Alright, good to know. Works now! Thanks for the help :PES_Ok:
Want results from more Discord servers?
Add your server