import type { DiscordWebhookClient } from '../discord/webhook.js';
import { EmbedBuilder } from '../discord/embed-builder.js';
import type { EmbedFieldParams } from './types.js';
import { ValidationError } from '../utils/errors.js';
export async function sendEmbedWithFields(
client: DiscordWebhookClient,
params: EmbedFieldParams
): Promise<string> {
// Validate fields
if (params.fields.length === 0) {
throw new ValidationError('At least one field must be provided');
}
// Build embed with fields
const builder = new EmbedBuilder();
builder.fromParams(params);
builder.addFields(params.fields);
const embed = builder.build();
// Send message with embed
const response = await client.send({
content: params.content,
username: params.username,
avatar_url: params.avatar_url,
embeds: [embed],
});
return `Embed with ${String(params.fields.length)} field(s) sent successfully (ID: ${response.id})`;
}