mirror of
https://github.com/danbulant/Shasha
synced 2026-09-20 06:43:51 +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() {
|
async function reset() {
|
||||||
await jobManager.stop().catch(console.error);
|
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();
|
await jobLoad();
|
||||||
jobManager.add(jobs);
|
jobManager.add(jobs);
|
||||||
|
|
@ -73,15 +76,15 @@ async function jobLoad() {
|
||||||
|
|
||||||
const rstjb = new Date((23 * 60 * 60 * 1000) + (30 * 60 * 1000)).valueOf();
|
const rstjb = new Date((23 * 60 * 60 * 1000) + (30 * 60 * 1000)).valueOf();
|
||||||
const rsttm = {
|
const rsttm = {
|
||||||
name: "rsttm",
|
name: "REFRESH JOBS",
|
||||||
path: join(__dirname, "./execSc.js"),
|
path: join(__dirname, "./execSc.js"),
|
||||||
worker: {
|
worker: {
|
||||||
argv: ["rsttm"]
|
argv: ["REFRESH JOBS"]
|
||||||
},
|
},
|
||||||
timeout: rstjb
|
timeout: rstjb
|
||||||
};
|
};
|
||||||
jobs.push(rsttm);
|
jobs.push(rsttm);
|
||||||
console.log(jobs.length + " JOBS LOADED");
|
console.log((jobs.length - 1) + " JOBS LOADED");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,9 @@ function scheduler(client, jobs = []) {
|
||||||
root: false,
|
root: false,
|
||||||
jobs: jobs,
|
jobs: jobs,
|
||||||
workerMessageHandler: ({ message }) => {
|
workerMessageHandler: ({ message }) => {
|
||||||
if (!message[0] || !message[1] || !message[2]) throw new Error("Value undefined!");
|
if (!message[0]) throw new Error("Value undefined!");
|
||||||
if (message === "rsttm") return require("../cmds/moderation/src/createSchedule").reset();
|
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]);
|
return execPunishmentSchedule(client, message[0], message[1], message[2]);
|
||||||
},
|
},
|
||||||
errorHandler: (e, m) => {
|
errorHandler: (e, m) => {
|
||||||
|
|
|
||||||
|
|
@ -410,14 +410,12 @@ Structures.extend("GuildMember", u => {
|
||||||
this.DB.muted.takenRoles = ROLES;
|
this.DB.muted.takenRoles = ROLES;
|
||||||
}
|
}
|
||||||
this.DB.muted.muteRole = this.guild.DB.settings.mute.role;
|
this.DB.muted.muteRole = this.guild.DB.settings.mute.role;
|
||||||
console.log(this.DB.muted.takenRoles);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (ROLES?.length > 0) await this.roles.remove(ROLES, reason);
|
if (ROLES?.length > 0) await this.roles.remove(ROLES, reason);
|
||||||
await this.roles.add(this.DB.muted.muteRole, reason);
|
await this.roles.add(this.DB.muted.muteRole, reason);
|
||||||
if (!this.DB.muted.takenRoles) this.DB.muted.takenRoles = [];
|
if (!this.DB.muted.takenRoles) this.DB.muted.takenRoles = [];
|
||||||
await this.setDb("muted", this.DB.muted);
|
await this.setDb("muted", this.DB.muted);
|
||||||
console.log(this.DB);
|
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (this.DB.muted.takenRoles?.length > 0) await this.roles.add(this.DB.muted.takenRoles, reason).catch(() => { });
|
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) {
|
async unmute(reason) {
|
||||||
if (!this.DB) await this.dbLoad();
|
if (!this.DB) await this.dbLoad();
|
||||||
try {
|
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.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);
|
if (this.DB.muted.muteRole) await this.roles.remove(this.DB.muted.muteRole, reason);
|
||||||
console.log("clear takenRoles UM");
|
console.log("clear takenRoles UM");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue