import { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, Colors } from "discord.js"; import type { PruneResult, PruneProgress } from "./prune.types"; /** * Creates a confirmation message for prune operations */ export function getConfirmationMessage( amount: number | 'all', estimatedCount?: number ): { embeds: EmbedBuilder[], components: ActionRowBuilder[] } { const isAll = amount === 'all'; const messageCount = isAll ? estimatedCount : amount; const embed = new EmbedBuilder() .setTitle("âš ī¸ Confirm Deletion") .setDescription( isAll ? `You are about to delete **ALL messages** in this channel.\n\n` + `Estimated messages: **~${estimatedCount || 'Unknown'}**\n` + `This action **cannot be undone**.` : `You are about to delete **${amount} messages**.\n\n` + `This action **cannot be undone**.` ) .setColor(Colors.Orange) .setTimestamp(); const confirmButton = new ButtonBuilder() .setCustomId("confirm_prune") .setLabel("Confirm") .setStyle(ButtonStyle.Danger); const cancelButton = new ButtonBuilder() .setCustomId("cancel_prune") .setLabel("Cancel") .setStyle(ButtonStyle.Secondary); const row = new ActionRowBuilder() .addComponents(confirmButton, cancelButton); return { embeds: [embed], components: [row] }; } /** * Creates a progress embed for ongoing deletions */ export function getProgressEmbed(progress: PruneProgress): EmbedBuilder { const percentage = Math.round((progress.current / progress.total) * 100); return new EmbedBuilder() .setTitle("🔄 Deleting Messages") .setDescription( `Progress: **${progress.current}/${progress.total}** (${percentage}%)\n\n` + `Please wait...` ) .setColor(Colors.Blue) .setTimestamp(); } /** * Creates a success embed after deletion */ export function getSuccessEmbed(result: PruneResult): EmbedBuilder { let description = `Successfully deleted **${result.deletedCount} messages**.`; if (result.filtered && result.username) { description = `Successfully deleted **${result.deletedCount} messages** from **${result.username}**.`; } if (result.skippedOld && result.skippedOld > 0) { description += `\n\nâš ī¸ **${result.skippedOld} messages** were older than 14 days and could not be deleted.`; } if (result.deletedCount < result.requestedCount && !result.skippedOld) { description += `\n\nâ„šī¸ Only **${result.deletedCount}** messages were available to delete.`; } return new EmbedBuilder() .setTitle("✅ Messages Deleted") .setDescription(description) .setColor(Colors.Green) .setTimestamp(); } /** * Creates an error embed */ export function getPruneErrorEmbed(message: string): EmbedBuilder { return new EmbedBuilder() .setTitle("❌ Prune Failed") .setDescription(message) .setColor(Colors.Red) .setTimestamp(); } /** * Creates a warning embed */ export function getPruneWarningEmbed(message: string): EmbedBuilder { return new EmbedBuilder() .setTitle("âš ī¸ Warning") .setDescription(message) .setColor(Colors.Yellow) .setTimestamp(); } /** * Creates a cancelled embed */ export function getCancelledEmbed(): EmbedBuilder { return new EmbedBuilder() .setTitle("đŸšĢ Deletion Cancelled") .setDescription("Message deletion has been cancelled.") .setColor(Colors.Grey) .setTimestamp(); }