mirror of
https://github.com/danbulant/Shasha
synced 2026-07-05 19:11:13 +00:00
Improvement (?)
This commit is contained in:
parent
41a0e03528
commit
fe71589989
2 changed files with 5 additions and 6 deletions
|
|
@ -36,7 +36,7 @@ async function createSchedule(client, { guildID, userID, type, until }) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await jobManager.remove(NAME).catch(() => { });
|
await jobManager.remove(NAME).catch(() => { });
|
||||||
if ((until.valueOf() - CHK) < new Date(0, 0, 0, 24, 0, 0, 0)) {
|
if ((until.valueOf() - CHK) < new Date(24 * 60 * 60 * 1000)) {
|
||||||
jobManager.add(SC);
|
jobManager.add(SC);
|
||||||
jobManager.start(NAME);
|
jobManager.start(NAME);
|
||||||
}
|
}
|
||||||
|
|
@ -68,10 +68,10 @@ async function reset() {
|
||||||
|
|
||||||
async function jobLoad() {
|
async function jobLoad() {
|
||||||
const CHK = new Date().valueOf();
|
const CHK = new Date().valueOf();
|
||||||
const CHK2 = new Date(0, 0, 0, 24, 0, 0, 0).valueOf();
|
const CHK2 = new Date(24 * 60 * 60 * 1000).valueOf();
|
||||||
jobs = (await col.find({}).toArray()).filter((v) => (v.date.valueOf() - CHK) < CHK2);
|
jobs = (await col.find({}).toArray()).filter((v) => (v.date.valueOf() - CHK) < CHK2);
|
||||||
|
|
||||||
const rstjb = new Date(0, 0, 0, 23, 30, 0, 0).valueOf();
|
const rstjb = new Date((23 * 60 * 60 * 1000) + (30 * 60 * 1000)).valueOf();
|
||||||
const rsttm = {
|
const rsttm = {
|
||||||
name: "rsttm",
|
name: "rsttm",
|
||||||
path: join(__dirname, "./execSc.js"),
|
path: join(__dirname, "./execSc.js"),
|
||||||
|
|
@ -89,7 +89,7 @@ function jobStart() {
|
||||||
const CHK = new Date().valueOf();
|
const CHK = new Date().valueOf();
|
||||||
jobManager.start();
|
jobManager.start();
|
||||||
jobs.forEach((v) => {
|
jobs.forEach((v) => {
|
||||||
if (v.date.valueOf() < CHK) jobManager.run(v.name);
|
if (v.date?.valueOf() < CHK) jobManager.run(v.name);
|
||||||
});
|
});
|
||||||
console.log("SCHEDULER STARTED");
|
console.log("SCHEDULER STARTED");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
const Bree = require("bree");
|
const Bree = require("bree");
|
||||||
const cabin = require("cabin");
|
const cabin = require("cabin");
|
||||||
const { Client } = require("discord.js");
|
const { Client } = require("discord.js");
|
||||||
const { reset } = require("../cmds/moderation/src/createSchedule");
|
|
||||||
const { errLog } = require("./functions");
|
const { errLog } = require("./functions");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -18,7 +17,7 @@ function scheduler(client, jobs = []) {
|
||||||
jobs: jobs,
|
jobs: jobs,
|
||||||
workerMessageHandler: ({ message }) => {
|
workerMessageHandler: ({ message }) => {
|
||||||
if (!message[0] || !message[1] || !message[2]) throw new Error("Value undefined!");
|
if (!message[0] || !message[1] || !message[2]) throw new Error("Value undefined!");
|
||||||
if (message === "rsttm") return reset();
|
if (message === "rsttm") return require("../cmds/moderation/src/createSchedule").reset();
|
||||||
return execPunishmentSchedule(client, message[0], message[1], message[2]);
|
return execPunishmentSchedule(client, message[0], message[1], message[2]);
|
||||||
},
|
},
|
||||||
errorHandler: (e, m) => {
|
errorHandler: (e, m) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue