import type { DiscordWebhookClient } from '../discord/webhook.js';
import type { SendMessageParams } from './types.js';
import { ValidationError } from '../utils/errors.js';
export async function sendMessage(
client: DiscordWebhookClient,
params: SendMessageParams
): Promise<string> {
// Validate content
if (!params.content || params.content.trim().length === 0) {
throw new ValidationError('Message content cannot be empty');
}
if (params.content.length > 2000) {
throw new ValidationError('Message content cannot exceed 2000 characters');
}
// Send message
const response = await client.send({
content: params.content,
username: params.username,
avatar_url: params.avatar_url,
});
return `Message sent successfully (ID: ${response.id})`;
}