File size: 2,118 Bytes
47ab1ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
let axios = require('axios');

let handler = async (m, { conn, text, usedPrefix, command }) => {
    if (!text) throw `Masukan URL!\n\ncontoh:\n${usedPrefix + command} https://vm.tiktok.com/ZGJAmhSrp/`;    
    try {
        if (!text.match(/tiktok/gi) && !text.match(/douyin/gi)) {
            throw `URL Tidak Ditemukan!`;
        }
        m.reply(wait);      

        try {
            const response = await axios.get(`https://btch.us.kg/download/v2/ttdl?url=${text}`);
            const res = response.data;

            if (!res.status) {
                throw `Gagal mendapatkan data!`;
            }

            const result = res.result;
            var { video, title, title_audio, audio, thumbnail } = result;

            if (!video || video.length === 0) {
                throw `Video tidak ditemukan!`;
            }

            let capt = `乂 *T I K T O K*\n\n`;
            capt += `◦ *Title* : ${title}\n`;
            capt += `◦ *Audio* : ${title_audio}\n`;
            capt += `◦ *Thumbnail* : ${thumbnail}\n`;
            capt += `\n`;

            if (video.length > 1) {
                for (let v of video) {
                    await conn.sendFile(m.chat, v, null, capt, m);
                }
            } else {
                await conn.sendFile(m.chat, video[0], null, capt, m);
            }

            if (!audio || audio.length === 0) {
                await conn.reply(m.chat, "_Audio tidak tersedia!_", m);
            } else {
                conn.sendMessage(m.chat, { audio: { url: audio[0] }, mimetype: 'audio/mpeg' }, { quoted: m });
            }
            return;
        } catch (e) {
            throw `Terjadi kesalahan saat mengambil data!`;
        }
    } catch (e) {
        throw `Terjadi kesalahan: ${e.message}`;
    }
};

handler.help = ['tiktok'];
handler.command = /^(tiktok|tt|tiktokdl|tiktoknowm)$/i;
handler.tags = ['downloader'];
handler.limit = true;
handler.group = false;
handler.premium = false;
handler.owner = false;
handler.admin = false;
handler.botAdmin = false;
handler.fail = null;
handler.private = false;

module.exports = handler;