chore: add more options to cleanup command
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user