-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathaudio-fast.js
31 lines (28 loc) · 1.15 KB
/
audio-fast.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const fs = require('fs')
const { exec } = require('child_process')
let handler = async (m, { conn, usedPrefix, command }) => {
try {
let q = m.quoted ? { message: { [m.quoted.mtype]: m.quoted } } : m
let mime = ((m.quoted ? m.quoted : m.msg).mimetype || '')
if (/audio/.test(mime)) {
let media = await conn.downloadAndSaveMediaMessage(q)
let ran = getRandom('.mp3')
exec(`ffmpeg -i ${media} -filter:a "atempo=1.63,asetrate=44100" ${ran}`, (err, stderr, stdout) => {
fs.unlinkSync(media)
if (err) throw `_*Error!*_`
let buff = fs.readFileSync(ran)
conn.sendFile(m.chat, buff, ran, null, m, true, { quoted: m, mimetype: 'audio/mp4' })
fs.unlinkSync(ran)
})
} else throw `Responda a una nota de voz o audio el cual desee modificar usando el comando *${usedPrefix + command}*`
} catch (e) {
throw e
}
}
handler.help = ['fast']
handler.tags = ['audio']
handler.command = /^(fast)$/i
module.exports = handler
const getRandom = (ext) => {
return `${Math.floor(Math.random() * 10000)}${ext}`
}