-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
help wantedExtra attention is neededExtra attention is needed
Description
I have a discord bot where one of the features is that on September 21st, it will send the youtube link the song "September". For some reason, these past two days it was running the task at noon. When trying to debug, it would also run on application restart. I'm wondering if there is an explanation to this behavior as I don't see why the code in its current state is allowing this behavior.
const db = require('../db');
const initTasks = require('@mongoosejs/task');
module.exports = async function tasks(bot) {
try {
const conn = await db().asPromise();
const setup = { db: conn }
initTasks(null, setup.db);
const { Task } = setup.db.models;
Task.registerHandler('september', function quirkMessage() {
return september(bot);
});
await Task.startPolling();
await Task.findOneAndUpdate({ name: 'september', status: 'pending' }, { scheduledAt: earthWindAndFire(), repeatAfterMS: millisecondsInYear }, { upsert: true, returnDocument: 'after' });
} catch(error) {
console.log('something went wrong registering all the handlers', error);
}
}
function earthWindAndFire() {
const date = new Date()
const year = date.getFullYear();
const septemberTwentyFirst = new Date(year, 8, 21, 19);
return septemberTwentyFirst;
}Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is needed