Scheduled Tasks not working

Hi, I've been trying to add the scheduled-tasks plugin but it doesn't seem to work, i honestly don't know what I'm doing wrong.
import { ScheduledTask } from '@sapphire/plugin-scheduled-tasks';

export class IntervalTask extends ScheduledTask {
public constructor(context: ScheduledTask.LoaderContext, options: ScheduledTask.Options) {
super(context, {
...options,
interval: 60_000 // 60 seconds
});
}

public async run() {
this.container.logger.info('I run every minute');
}
}

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

export class IntervalTask extends ScheduledTask {
public constructor(context: ScheduledTask.LoaderContext, options: ScheduledTask.Options) {
super(context, {
...options,
interval: 60_000 // 60 seconds
});
}

public async run() {
this.container.logger.info('I run every minute');
}
}

declare module '@sapphire/plugin-scheduled-tasks' {
interface ScheduledTasks {
interval: never;
}
}
I implemented this Success event but it's not logging anything
import { Listener } from '@sapphire/framework';
import { ScheduledTask, ScheduledTaskEvents, ScheduledTaskOptions } from '@sapphire/plugin-scheduled-tasks';

export class ScheduledTaskSuccessListener extends Listener<typeof ScheduledTaskEvents.ScheduledTaskSuccess> {
public constructor(context: Listener.LoaderContext, options: Listener.Options) {
super(context, {
event: ScheduledTaskEvents.ScheduledTaskSuccess,
once: false
});
}

public async run(task: ScheduledTask<"interval", ScheduledTaskOptions>): Promise<void> {
this.container.logger.info(`Scheduled task "${task}" completed successfully.`);
}
}
import { Listener } from '@sapphire/framework';
import { ScheduledTask, ScheduledTaskEvents, ScheduledTaskOptions } from '@sapphire/plugin-scheduled-tasks';

export class ScheduledTaskSuccessListener extends Listener<typeof ScheduledTaskEvents.ScheduledTaskSuccess> {
public constructor(context: Listener.LoaderContext, options: Listener.Options) {
super(context, {
event: ScheduledTaskEvents.ScheduledTaskSuccess,
once: false
});
}

public async run(task: ScheduledTask<"interval", ScheduledTaskOptions>): Promise<void> {
this.container.logger.info(`Scheduled task "${task}" completed successfully.`);
}
}
any help will be appreciated :)
Solution:
also you're missing /register here
No description
Jump to solution
6 Replies
Favna
Favna7mo ago
Did you follow the instructions on the readme? Configured the client and called the register?
Favna
Favna7mo ago
GitHub
plugins/packages/scheduled-tasks/README.md at main · sapphiredev/pl...
Plugins for the Sapphire Framework. Contribute to sapphiredev/plugins development by creating an account on GitHub.
dazx
dazxOP7mo ago
I did. This is my main file
import '@sapphire/plugin-subcommands/register';
import '@sapphire/plugin-i18next/register';
import '@sapphire/plugin-scheduled-tasks'
import { bannerLoad } from "@shared/functions/bannerLoad";
import { Client } from "@app/client";
import { Run as app } from "@app/run";

async function main() {
const client = new Client();
await app.clientRun(client);
}

void main().then(() => {
bannerLoad()
});
import '@sapphire/plugin-subcommands/register';
import '@sapphire/plugin-i18next/register';
import '@sapphire/plugin-scheduled-tasks'
import { bannerLoad } from "@shared/functions/bannerLoad";
import { Client } from "@app/client";
import { Run as app } from "@app/run";

async function main() {
const client = new Client();
await app.clientRun(client);
}

void main().then(() => {
bannerLoad()
});
And this is my tasks configuration in the client
tasks: {
bull: {
connection: {
port: config.database.redis.port,
host: config.database.redis.host,
}
}
},
tasks: {
bull: {
connection: {
port: config.database.redis.port,
host: config.database.redis.host,
}
}
},
I'm already using ioredis for a few other things in my bot, so i selected another db but still not working
Favna
Favna7mo ago
you didnt config the db there?
tasks: {
bull: {
connection: {
port: envParseInteger('REDIS_PORT'),
password: envParseString('REDIS_PASSWORD'),
host: envParseString('REDIS_HOST')
db: envParseInteger('REDIS_TASK_DB')
}
}
}
tasks: {
bull: {
connection: {
port: envParseInteger('REDIS_PORT'),
password: envParseString('REDIS_PASSWORD'),
host: envParseString('REDIS_HOST')
db: envParseInteger('REDIS_TASK_DB')
}
}
}
This is what I have for @Dragonite
Solution
Favna
Favna7mo ago
also you're missing /register here
No description
dazx
dazxOP7mo ago
It was the /register thing, i can't believe i was on this for hours. Thank you so much
Want results from more Discord servers?
Add your server