import { Command } from 'commander' import { handleError } from '@/shared/utils/error-handler' import { formatOutput } from '@/shared/utils/output' import { type BotOption, getClient } from './shared' async function addAction(channelInput: string, timestamp: string, emoji: string, options: BotOption): Promise { try { const client = await getClient(options) const channel = await client.resolveChannel(channelInput) await client.addReaction(channel, timestamp, emoji) console.log(formatOutput({ success: true, channel, timestamp, emoji }, options.pretty)) } catch (error) { handleError(error as Error) } } async function removeAction(channelInput: string, timestamp: string, emoji: string, options: BotOption): Promise { try { const client = await getClient(options) const channel = await client.resolveChannel(channelInput) await client.removeReaction(channel, timestamp, emoji) console.log(formatOutput({ success: true, channel, timestamp, emoji }, options.pretty)) } catch (error) { handleError(error as Error) } } export const reactionCommand = new Command('reaction') .description('Reaction commands') .addCommand( new Command('add') .description('Add a reaction to a message') .argument('', 'Channel ID or name') .argument('', 'Message timestamp') .argument('', 'Emoji name (with or without colons)') .option('--bot ', 'Use specific bot') .option('--pretty', 'Pretty print JSON output') .action(addAction), ) .addCommand( new Command('remove') .description('Remove a reaction from a message') .argument('', 'Channel ID or name') .argument('', 'Message timestamp') .argument('', 'Emoji name (with or without colons)') .option('--bot ', 'Use specific bot') .option('--pretty', 'Pretty print JSON output') .action(removeAction), )