import { Message } from "discord.js"; import { replyWithCleanup } from "../utilities"; export const handleSaycCommand = async (message: Message): Promise => { if (message.author.bot) return false; const content = message.content.trim(); const commandMatch = content.match(/^uma!sayc\s+(\d+)\s+(.+)$/s); if (!commandMatch) return false; const [, channelId, messageContent] = commandMatch; if (!messageContent.trim()) { await replyWithCleanup( message, "❌ You need to provide a message to send.", ); return true; } try { const targetChannel = message.client.channels.cache.get(channelId); if ( !targetChannel || !targetChannel.isTextBased() || targetChannel.isDMBased() ) { await replyWithCleanup( message, "❌ Channel not found or is not a text channel.", ); return true; } await targetChannel.send(messageContent); await replyWithCleanup(message, `✅ Message sent to <#${channelId}>.`); return true; } catch (error) { console.error("Error in sayc command:", error); await replyWithCleanup( message, "❌ Failed to send message to the specified channel.", ); return true; } };