fix: address code review feedback

- Remove unused ffmpeg astats command from generateWaveform()
- Use crypto.randomUUID() for temp file names to prevent collision
- Wrap upload URL request in retry runner for consistency
- Add validation: reject content with asVoice, require local file path
- Add clarifying comments for CDN upload behavior
This commit is contained in:
nyanjou
2026-02-02 17:23:08 +01:00
committed by Shadow
parent 36525a974e
commit b9da2c4679
2 changed files with 32 additions and 37 deletions

View File

@@ -240,9 +240,20 @@ export async function handleDiscordMessagingAction(
Array.isArray(params.embeds) && params.embeds.length > 0 ? params.embeds : undefined;
// Handle voice message sending
if (asVoice && mediaUrl) {
// Voice messages require a local file path or downloadable URL
// They cannot include text content (Discord limitation)
if (asVoice) {
if (!mediaUrl) {
throw new Error("Voice messages require a media file path (mediaUrl).");
}
if (content && content.trim()) {
throw new Error(
"Voice messages cannot include text content (Discord limitation). Remove the content parameter.",
);
}
if (mediaUrl.startsWith("http://") || mediaUrl.startsWith("https://")) {
throw new Error(
"Voice messages require a local file path, not a URL. Download the file first.",
);
}
const result = await sendVoiceMessageDiscord(to, mediaUrl, {
...(accountId ? { accountId } : {}),
replyTo,