From 69186ff3e942fbf18f846d755ac146cf8ad6c2cd Mon Sep 17 00:00:00 2001 From: syntaxbullet Date: Tue, 6 Jan 2026 19:44:18 +0100 Subject: [PATCH] chore: add more options to cleanup command --- src/commands/admin/cleanup.ts | 40 +++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/commands/admin/cleanup.ts b/src/commands/admin/cleanup.ts index 0980e76..a02914b 100644 --- a/src/commands/admin/cleanup.ts +++ b/src/commands/admin/cleanup.ts @@ -13,12 +13,15 @@ export const cleanup = createCommand({ .setDescription("The type of cleanup to perform") .setRequired(true) .addChoices( - { name: 'Lootdrops', value: 'lootdrops' } + { name: 'Lootdrops', value: 'lootdrops' }, + { name: 'Timers (Expired)', value: 'timers' }, + { name: 'Quests (Old Completed)', value: 'quests' }, + { name: 'All', value: 'all' } ) ) .addBooleanOption(option => option.setName("include_claimed") - .setDescription("Whether to cleanup claimed lootdrops as well (only for lootdrops type)") + .setDescription("Whether to cleanup claimed lootdrops as well (only for lootdrops/all)") .setRequired(false) ), execute: async (interaction) => { @@ -28,13 +31,38 @@ export const cleanup = createCommand({ const includeClaimed = interaction.options.getBoolean("include_claimed") || false; try { - let count = 0; - if (type === 'lootdrops') { - count = await lootdropService.cleanupExpiredLootdrops(includeClaimed); + let stats = { + lootdrops: 0, + timers: 0, + quests: 0 + }; + + const runLootdrops = type === 'lootdrops' || type === 'all'; + const runTimers = type === 'timers' || type === 'all'; + const runQuests = type === 'quests' || type === 'all'; + + const messages: string[] = []; + + if (runLootdrops) { + stats.lootdrops = await lootdropService.cleanupExpiredLootdrops(includeClaimed); + messages.push(`- **Lootdrops**: ${stats.lootdrops} removed ${includeClaimed ? "(including claimed)" : ""}`); + } + + if (runTimers) { + // Import dynamically to avoid circular deps if any, or just standard import + const { cleanupService } = await import("@/modules/system/cleanup.service"); + stats.timers = await cleanupService.cleanupTimers(); + messages.push(`- **Timers**: ${stats.timers} expired timers processing/removed`); + } + + if (runQuests) { + const { cleanupService } = await import("@/modules/system/cleanup.service"); + stats.quests = await cleanupService.cleanupQuests(); + messages.push(`- **Quests**: ${stats.quests} archived/removed`); } const embed = createBaseEmbed("Cleanup Complete") - .setDescription(`Successfully executed cleanup for **${type}**.\nDeleted **${count}** records. ${includeClaimed ? "\n(Included claimed items)" : ""}`); + .setDescription(`successfully executed cleanup for **${type}**.\n\n${messages.join("\n")}`); await interaction.editReply({ embeds: [embed] }); } catch (error) {