Anthony
Anthony
Explore posts from servers
SIASapphire - Imagine a framework
Created by Anthony on 2/16/2023 in #sapphire-support
Manual task not executing
Hiya, One of the tasks for a temp ban doesn't seem to execute after the amount of time I specified in the command. I've played around with other tasks that have worked before and still do work, updated the modules that are related to this and also delete the redis database after. I've also looked around and I don't think it's related to this: https://discord.com/channels/737141877803057244/1074660009117499413 because other pattern tasks have been working for a while, and I've gotten other called tasks to execute after 9 seconds. Versions of the modules: @sapphire/framework: 4.1.0 @sapphire/plugin-scheduled-tasks: 6.0.0 bullmq: 3.6.6 I'm also not using any modules that are currently in any betas/alphas. Snippets of the code: Snippet of the code in the application command: I am also using Duration from @sapphire/time-utilities for the variable time.
this.container.tasks.create('tempBan', {
userId: user.id,
guildId: guild.id,
}, time.offset);
this.container.logger.debug(`Temp Ban: ban time ${time.offset}`);
this.container.tasks.create('tempBan', {
userId: user.id,
guildId: guild.id,
}, time.offset);
this.container.logger.debug(`Temp Ban: ban time ${time.offset}`);
This command also works, it does ban the user and sends a log in a channel. Scheduled Task:
import { ScheduledTask } from '@sapphire/plugin-scheduled-tasks';

export class TempBan extends ScheduledTask {
public constructor(context: ScheduledTask.Context, options: ScheduledTask.Options) {
super(context, options);
}

public async run(payload: { userId: string, guildId: string }) {
this.container.logger.debug('Temp Unban Task: Currently running unban');
// More code, removed it just to not clog up the thread
}
}

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

export class TempBan extends ScheduledTask {
public constructor(context: ScheduledTask.Context, options: ScheduledTask.Options) {
super(context, options);
}

public async run(payload: { userId: string, guildId: string }) {
this.container.logger.debug('Temp Unban Task: Currently running unban');
// More code, removed it just to not clog up the thread
}
}

declare module '@sapphire/plugin-scheduled-tasks' {
interface ScheduledTasks {
tempBan: never;
}
}
This is the only log I got in the console:
2023-02-16 17:55:38 - DEBUG - Temp Ban: ban time 30000
2023-02-16 17:55:38 - DEBUG - Temp Ban: ban time 30000
I would be happy to provide the code for the entire git repo with commands that work, or make a git repo with snippets of the code only related to temp bans.
12 replies