Skip to content

Commit

Permalink
clearing empty schedule shouldn't throw error
Browse files Browse the repository at this point in the history
  • Loading branch information
Davoleo committed May 12, 2024
1 parent 383e57a commit 1e00a38
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
21 changes: 1 addition & 20 deletions src/commands/updatestuff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,9 @@ import {CommandInteraction} from "discord.js";
import Command from "../model/Command.js";
import {CommandScope} from "../model/CommandGroup.js";
import {CommandPermission} from "../util/discord.js";
import CacheManager from "../services/CacheService.js";

function updatestuff(interaction: CommandInteraction) {

CacheManager.getAllProjects().then(projects => {

if (projects.length === 0) {
interaction.reply('dogsong intensifies');
return [];
}

const transactionId = "$CLEANUP_COMMAND$"

const promises = [];
for (const project of projects) {
promises.push(CacheManager.cleanupProject(project.id, transactionId));
}
return Promise.all(promises);
}).then(
cleanUpFlags => cleanUpFlags.map(flag => flag ? 1 : 0)
.reduce((a, b) => a + b, 0))
.then(value => interaction.reply(`Cache cleanup found ${value} useless projects!`));
void interaction.reply('dogsong intensifies');
}

export const command = new Command(
Expand Down
2 changes: 1 addition & 1 deletion src/services/GuildService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default class GuildService {
throw new UninitializedGuildError(serverId);

if (projNumbers.projects.length === 0) {
throw Error("Schedule is already empty!")
return;
}

await dbclient.serverConfig.update({
Expand Down

0 comments on commit 1e00a38

Please sign in to comment.