import { Message } from "discord.js"; import { sendProgressUpdate, executeBulkRoleAssignment } from "./utilities"; export const handleStartCommand = async (message: Message) => { if (message.author.bot) return; if (message.content.toLowerCase().startsWith("uma!start")) { const application = await message.client.application?.fetch(); const ownerId = application?.owner?.id; if (message.author.id !== ownerId) return; const parameters = message.content.split(" ").slice(1); if (parameters.length < 3) { await message.reply( "❌ Usage: `uma!start [action]`\nExample: `uma!start @Participant #general 1415599617214513254 execute`", ); return; } const roleMention = parameters[0]; const channelOrCategory = parameters[1]; const updateChannelId = parameters[2]; const action = parameters[3] || "execute"; const roleMatch = roleMention.match(/<@&(\d+)>/); if (!roleMatch) { await message.reply("❌ Please mention a role. Example: `@Participant`"); return; } const roleId = roleMatch[1]; let channelId: string | undefined; let categoryId: string | undefined; const channelMatch = channelOrCategory.match(/<#(\d+)>/); if (channelMatch) { channelId = channelMatch[1]; } else { categoryId = channelOrCategory; } if (action !== "preview" && action !== "execute") { await message.reply("❌ Action must be either `preview` or `execute`"); return; } if (action === "preview") { await message.reply( "📋 Preview mode - this would check the specified channel(s) for users who have sent messages.", ); return; } await message.reply( "🚀 Bulk role operation started! Check the progress channel for updates.", ); executeBulkRoleAssignment( message.client, roleId, updateChannelId, channelId, categoryId, ).catch((error) => { console.error("Bulk role assignment failed:", error); sendProgressUpdate( message.client, "❌ Bulk role assignment failed due to an error", updateChannelId, ); }); } };