const sendAudio = async (audioKey) => {
try {
const media = MessageMedia.fromFilePath(mediaFiles[audioKey]);
const chat = await client.getChatById(from);
console.log('Chat ID:', from);
await chat.sendMessage(media, { sendAudioAsVoice: true });
console.log('Áudio enviado com sucesso!');
} catch (error) {
console.error('Erro ao enviar o áudio:', error.message);
console.error(error);
}
};
---------------------------------------------------------------------------------------
case 4:
if (messageBody.includes('sim') || messageBody === 's') {
await sendMessage("Vou enviar o áudio explicativo para você agora!");
await sendAudio('audioExplicativo');
await sendMessage("Agora que você tem uma ideia de como funciona, quais dessas regiões é do seu interesse? Entorno do DF, Interior de Goiás ou Grande Goiânia?");
conversation.step = 6;
} else if (messageBody.includes('não') || messageBody.includes('nao') || messageBody === 'n') {
await sendMessage("Ok, vou te enviar o link do nosso portal onde você encontrará mais informações: https://leilaoimoveisgoiania.com.br/.");
delete conversations[from];
} else {
await sendMessage("Por favor, responda com 'sim' ou 'não'.");
}
break;
The rest of the code is working fine, sending texts, going for one stage or another, and replying to texts, but the audio wont be sent, even tho in the terminal it says so