Skip to content

Commit

Permalink
更新 admin可以看到整個server 的cron 和at
Browse files Browse the repository at this point in the history
  • Loading branch information
zeteticl committed Feb 25, 2024
1 parent ee93197 commit b9a87a4
Showing 1 changed file with 32 additions and 7 deletions.
39 changes: 32 additions & 7 deletions roll/z_schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const rollDiceCommand = async function ({
return rply
}
let check = {}
if (botname == "Discord") {
if (botname == "Discord" && userrole < 3) {
check = {
name: differentPeformAt(botname),
"data.channelid": channelid,
Expand All @@ -131,6 +131,18 @@ const rollDiceCommand = async function ({
check
).catch(error => console.error('agenda error: ', error.name, error.reson))
rply.text = showJobs(jobs);
if (userrole == 3 && botname == "Discord") {
rply.text = `\n本頻道列表\n\n${rply.text}`
check = {
name: differentPeformAt(botname),
"data.groupid": groupid
}
const jobs = await agenda.agenda.jobs(
check
).catch(error => console.error('agenda error: ', error.name, error.reson))
rply.text = `本群組列表\n\n${showJobs(jobs)} \n\n${rply.text
} `;
}
return rply;
}
case /^\.at+$/i.test(mainMsg[0]) && /^delete$/i.test(mainMsg[1]): {
Expand All @@ -144,7 +156,7 @@ const rollDiceCommand = async function ({
return rply
}
let check = {}
if (botname == "Discord") {
if (botname == "Discord" && userrole < 3) {
check = {
name: differentPeformAt(botname),
"data.channelid": channelid,
Expand Down Expand Up @@ -233,7 +245,7 @@ const rollDiceCommand = async function ({
}

let check = {}
if (botname == "Discord") {
if (botname == "Discord" && userrole < 3) {
check = {
name: differentPeformCron(botname),
"data.channelid": channelid,
Expand All @@ -247,6 +259,18 @@ const rollDiceCommand = async function ({
check
).catch(error => console.error('agenda error: ', error.name, error.reson))
rply.text = showCronJobs(jobs);
if (userrole == 3 && botname == "Discord") {
rply.text = `\n本頻道列表\n\n${rply.text}`
check = {
name: differentPeformCron(botname),
"data.groupid": groupid
}
const jobs = await agenda.agenda.jobs(
check
).catch(error => console.error('agenda error: ', error.name, error.reson))
rply.text = `本群組列表\n\n${showCronJobs(jobs)} \n\n${rply.text
} `;
}
return rply;
}
case /^\.cron$/i.test(mainMsg[0]) && /^delete$/i.test(mainMsg[1]): {
Expand All @@ -263,13 +287,14 @@ const rollDiceCommand = async function ({
return rply
}
let check = {}
if (botname == "Discord") {
if (botname == "Discord" && userrole < 3) {
check = {
name: differentPeformCron(botname),
"data.channelid": channelid,
"data.groupid": groupid
}
} else check = {
}
else check = {
name: differentPeformCron(botname),
"data.groupid": groupid
}
Expand All @@ -279,7 +304,7 @@ const rollDiceCommand = async function ({
try {
let data = jobs[Number(mainMsg[2]) - 1];
await jobs[Number(mainMsg[2]) - 1].remove();
rply.text = `已刪除序號#${Number(mainMsg[2])} \n${data.attrs.data.replyText}`;
rply.text = `已刪除序號#${Number(mainMsg[2])} \n${data.attrs.data.replyText} `;

} catch (e) {
console.error("Remove Cron Error removing job from collection, input: ", inputStr);
Expand Down Expand Up @@ -317,7 +342,7 @@ const rollDiceCommand = async function ({

let checkTime = checkCronTime(mainMsg[1]);
if (!checkTime || !checkTime.min || !checkTime.hour) {
rply.text = `輸入出錯\n ${this.getHelpMessage()}`;
rply.text = `輸入出錯\n ${this.getHelpMessage()} `;
return rply;
}
if (roleName.roleName || roleName.imageLink) {
Expand Down

0 comments on commit b9a87a4

Please sign in to comment.