mirror of
https://github.com/danbulant/Shasha
synced 2026-09-18 05:43:55 +00:00
Final improvement (?)
This commit is contained in:
parent
fe71589989
commit
d82661d347
3 changed files with 10 additions and 9 deletions
|
|
@ -58,7 +58,10 @@ async function init(client) {
|
|||
|
||||
async function reset() {
|
||||
await jobManager.stop().catch(console.error);
|
||||
await jobManager.remove().catch(console.error);
|
||||
for (const job of jobs) {
|
||||
await jobManager.remove(job.name).catch(console.error);
|
||||
console.log("REMOVED " + job.name);
|
||||
}
|
||||
|
||||
await jobLoad();
|
||||
jobManager.add(jobs);
|
||||
|
|
@ -73,15 +76,15 @@ async function jobLoad() {
|
|||
|
||||
const rstjb = new Date((23 * 60 * 60 * 1000) + (30 * 60 * 1000)).valueOf();
|
||||
const rsttm = {
|
||||
name: "rsttm",
|
||||
name: "REFRESH JOBS",
|
||||
path: join(__dirname, "./execSc.js"),
|
||||
worker: {
|
||||
argv: ["rsttm"]
|
||||
argv: ["REFRESH JOBS"]
|
||||
},
|
||||
timeout: rstjb
|
||||
};
|
||||
jobs.push(rsttm);
|
||||
console.log(jobs.length + " JOBS LOADED");
|
||||
console.log((jobs.length - 1) + " JOBS LOADED");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,9 @@ function scheduler(client, jobs = []) {
|
|||
root: false,
|
||||
jobs: jobs,
|
||||
workerMessageHandler: ({ message }) => {
|
||||
if (!message[0] || !message[1] || !message[2]) throw new Error("Value undefined!");
|
||||
if (message === "rsttm") return require("../cmds/moderation/src/createSchedule").reset();
|
||||
if (!message[0]) throw new Error("Value undefined!");
|
||||
if (message[0] === "REFRESH JOBS") return require("../cmds/moderation/src/createSchedule").reset();
|
||||
if (!message[1] || !message[2]) throw new Error("Name undefined!");
|
||||
return execPunishmentSchedule(client, message[0], message[1], message[2]);
|
||||
},
|
||||
errorHandler: (e, m) => {
|
||||
|
|
|
|||
|
|
@ -410,14 +410,12 @@ Structures.extend("GuildMember", u => {
|
|||
this.DB.muted.takenRoles = ROLES;
|
||||
}
|
||||
this.DB.muted.muteRole = this.guild.DB.settings.mute.role;
|
||||
console.log(this.DB.muted.takenRoles);
|
||||
|
||||
try {
|
||||
if (ROLES?.length > 0) await this.roles.remove(ROLES, reason);
|
||||
await this.roles.add(this.DB.muted.muteRole, reason);
|
||||
if (!this.DB.muted.takenRoles) this.DB.muted.takenRoles = [];
|
||||
await this.setDb("muted", this.DB.muted);
|
||||
console.log(this.DB);
|
||||
return true;
|
||||
} catch (e) {
|
||||
if (this.DB.muted.takenRoles?.length > 0) await this.roles.add(this.DB.muted.takenRoles, reason).catch(() => { });
|
||||
|
|
@ -432,7 +430,6 @@ Structures.extend("GuildMember", u => {
|
|||
async unmute(reason) {
|
||||
if (!this.DB) await this.dbLoad();
|
||||
try {
|
||||
console.log(this.DB);
|
||||
if (this.DB.muted.takenRoles.length > 0) await this.roles.add(this.DB.muted.takenRoles, reason);
|
||||
if (this.DB.muted.muteRole) await this.roles.remove(this.DB.muted.muteRole, reason);
|
||||
console.log("clear takenRoles UM");
|
||||
|
|
|
|||
Loading…
Reference in a new issue