Manual task not triggering

im trying to create an unmute task but it doesnt seems to get triggered that reliably I also tried copy pasting the documentation code for manual and it also gets triggered rarely here are some snippets of my code UnmuteUserTask.ts https://raw.githubusercontent.com/TheOreoTM/cardinal-bot/main/src/scheduled-tasks/UnmuteMemberTask.ts And i call it in a Class i have named Modlog Modlog.ts
export class Modlog {
// code
public async createMute(data: MuteCreateInput) {
const mute = await container.db.mute.create({
data: {
expiresAt: data.expiresAt,
memberId: this.memberId,
removedRoles: data.removedRoles ? data.removedRoles : [],
modlog: {
create: await this.createModlog()
}
}
});

if (data.expiresAt) {
const offset = data.expiresAt.getTime() - Date.now();
console.log(offset);
container.tasks.create('UnmuteMemberTask', { muteId: mute.id }, offset);
}

await this.sendModlog(mute.modlogId);

return this;
}
// code
}
export class Modlog {
// code
public async createMute(data: MuteCreateInput) {
const mute = await container.db.mute.create({
data: {
expiresAt: data.expiresAt,
memberId: this.memberId,
removedRoles: data.removedRoles ? data.removedRoles : [],
modlog: {
create: await this.createModlog()
}
}
});

if (data.expiresAt) {
const offset = data.expiresAt.getTime() - Date.now();
console.log(offset);
container.tasks.create('UnmuteMemberTask', { muteId: mute.id }, offset);
}

await this.sendModlog(mute.modlogId);

return this;
}
// code
}
and this class is called in the mute command Here my are versions "@sapphire/plugin-scheduled-tasks": "^8.0.0" "@sapphire/framework": "^4.5.1"
7 Replies
Oreo ™
Oreo ™OP14mo ago
What am i doing wrong? i have also setup listeners for ScheduledTasksEvents.TaskRun and TaskNotFound And none of them were helpful
Oreo ™
Oreo ™OP14mo ago
Here is a ss of the logs
No description
Oreo ™
Oreo ™OP14mo ago
and the only occurence when the task actually ran the not found expireMute is my old scheduled task that was on an interval and i had it disabled
Favna
Favna14mo ago
fraid this will be on the bullmq package as the plugin is merely a tiny wrapper around it so you'll have to ask for support at wherever you can get bullmq support.
KB
KB14mo ago
Not sure how much it would help but container.tasks.create is async, try throwing an await in front.
Oreo ™
Oreo ™OP14mo ago
hm ok Also can you inform me on what removeOnComplete does exactly? and where would i use it
Favna
Favna14mo ago
refer to the bullmq docs for all the info
Want results from more Discord servers?
Add your server