refactor: replace cleanup service with focused temp role service and fix daily streaks

This commit is contained in:
syntaxbullet
2026-01-07 11:04:34 +01:00
parent 4a1e72c5f3
commit ca392749e3
9 changed files with 206 additions and 341 deletions

View File

@@ -1,73 +0,0 @@
import { createCommand } from "@lib/utils";
import { SlashCommandBuilder, PermissionFlagsBits } from "discord.js";
import { lootdropService } from "@/modules/economy/lootdrop.service";
import { createBaseEmbed } from "@lib/embeds";
export const cleanup = createCommand({
data: new SlashCommandBuilder()
.setName("cleanup")
.setDescription("Manually trigger cleanup tasks")
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addStringOption(option =>
option.setName("type")
.setDescription("The type of cleanup to perform")
.setRequired(true)
.addChoices(
{ 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/all)")
.setRequired(false)
),
execute: async (interaction) => {
await interaction.deferReply({ ephemeral: true });
const type = interaction.options.getString("type", true);
const includeClaimed = interaction.options.getBoolean("include_claimed") || false;
try {
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}**.\n\n${messages.join("\n")}`);
await interaction.editReply({ embeds: [embed] });
} catch (error) {
console.error("Cleanup failed:", error);
await interaction.editReply({ content: "❌ An error occurred while performing cleanup." });
}
}
});