-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCybertmp.js
29 lines (22 loc) · 1.04 KB
/
Cybertmp.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
import { toAudio } from '../../lib/converter.cjs';
import config from '../../config.cjs';
const tomp3 = async (m, gss) => {
try {
const prefix = config.PREFIX;
const cmd = m.body.startsWith(prefix) ? m.body.slice(prefix.length).split(' ')[0].toLowerCase() : '';
const text = m.body.slice(prefix.length + cmd.length).trim();
const validCommands = ['tomp3', 'mp3'];
if (!validCommands.includes(cmd)) return;
if (!m.quoted || m.quoted.mtype !== 'videoMessage') {
return m.reply(`Send/Reply with Video to convert into MP3 with caption ${prefix + cmd}`);
}
m.reply('Converting to MP3, please wait...');
const media = await m.quoted.download();
const audio = await toAudio(media, 'mp4'); // Correctly importing toAudio function
await gss.sendMessage(m.from, { document: audio, mimetype: 'audio/mpeg', fileName: `Converted By ${gss.user.name}.mp3` }, { quoted: m });
} catch (error) {
console.error('Error:', error);
m.reply('An error occurred while processing the command.');
}
};
export default tomp3;