bug fixes

This commit is contained in:
liyunze 2024-05-11 14:36:07 +08:00
parent deb9344950
commit 6a963d028c
3 changed files with 32 additions and 8 deletions

View file

@ -335,6 +335,7 @@ const defaultConfigs = (function () {
clearedTasks: "All {taskName}s have been cleared, {user}!",
adminDeleteTasks: "All of {mentioned}'s {taskName}s have been deleted",
clearedAll: "All {taskName}s and points have been cleared, {user}!",
clearedDone: "All completed {taskName}s have been cleared, {user}!",
// Grouped by task completion responses
taskFinished:

View file

@ -80,16 +80,25 @@ async function processCommand(user, command, message, flags, extra) {
}
let finishedResponse = getResponse("taskFinished");
params.task = finishRequest.body.markedTasks;
params.doneCount = await completedTasksCount(user);
params.pointCount =
finishRequest.body.markedTasksCount * getSetting("pointsPerTask");
if (finishRequest.body.failedTasks !== "") {
finishedResponse += ` | Failed to finish task(s): "${finishRequest.body.failedTasks}"`;
finishedResponse += ` | Failed to finish {taskName}(s): "${finishRequest.body.failedTasks}"`;
}
finishedResponse = finishedResponse.replaceAll(
"{pointName}",
getSetting("pointsName")
);
finishedResponse = finishedResponse.replaceAll(
"{taskName}",
getSetting("taskName")
);
respond(finishedResponse, params);
} else if (getCommand("unfinishTaskCommands").includes(command)) {
let unfinishRequest = await markTaskUndone(user, message);
@ -165,6 +174,7 @@ async function processCommand(user, command, message, flags, extra) {
respond(unfocusedResponse, params);
} else if (getCommand("checkCommands").includes(command)) {
var checkingUser = user;
if (message === "") {
let checkRequest = await checkTasks(user);
if (checkRequest.status !== 200) {
@ -183,7 +193,10 @@ async function processCommand(user, command, message, flags, extra) {
.join(" | ")
.replaceAll("{taskName}", getSetting("taskName"));
await respond(`{user} {tasks}`, params);
params.checkingUser = checkingUser;
await respond(`{checkingUser} {tasks}`, params);
await sleep(200);
}
// return respond(checkRequest.body.reply, params);
@ -203,9 +216,14 @@ async function processCommand(user, command, message, flags, extra) {
// respond every 10 tasks
for (let i = 0; i < incompleteTasks.length; i += 10) {
let tasks = incompleteTasks.slice(i, i + 10);
params.tasks = tasks.join(" | ");
params.tasks = tasks
.join(" | ")
.replaceAll("{taskName}", getSetting("taskName"));
await respond(`{user} {tasks}`, params);
params.checkingUser = checkingUser;
await respond(`{checkingUser} {tasks}`, params);
await sleep(200);
}
}
} else if (getCommand("adminDeleteCommands").includes(command)) {
@ -484,7 +502,7 @@ async function processCommand(user, command, message, flags, extra) {
let leaderboard = leaderboardResponse.body.leaderboard;
respond(leaderboard, params);
await respond(leaderboard, params);
} else if (getCommand("adminSetBoardCountCommands").includes(command)) {
if (!isStreamer(flags)) {
respond(getResponse("notStreamer"), params);

View file

@ -721,9 +721,11 @@ async function leaderboardTaskCount(limit) {
let leaderboardArray = [];
for (const user in counts.users) {
let userTaskCount = await completedTasksCount(user);
leaderboardArray.push({
username: user,
taskCount: getUserTotalTaskCount(user),
taskCount: userTaskCount,
});
}
@ -2134,6 +2136,8 @@ async function clearUserTasks(username) {
async function clearAllDoneTasks() {
const tasks = await DBHandler.get("tasks");
for (const user in tasks) {
if (!tasks[user].todos) continue;
if (user.toLowerCase() === "id") continue;
tasks[user].todos = tasks[user].todos.filter((t) => !t.done);
}
cancelAnimation();
@ -2147,6 +2151,7 @@ async function clearAllDoneTasks() {
async function clearAllTasks() {
await DBHandler.set("tasks", {});
await setupDB();
cancelAnimation();
await renderTaskListToDOM();
@ -2156,7 +2161,7 @@ async function clearAllTasks() {
}
async function clearAll() {
resetDB();
await resetDB();
cancelAnimation();
checkToAnimate();
await renderTaskListToDOM();