Created
December 12, 2025 14:20
-
-
Save Reyz2902/4e58f9c9e15aedbd6e96fc9198034dd2 to your computer and use it in GitHub Desktop.
Uploaded via Theresa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const axios = require('axios'); | |
| const handler = async (m, { | |
| conn, | |
| args, | |
| usedPrefix, | |
| command | |
| }) => { | |
| if (!args[0]) { | |
| return m.reply(`Usage: ${usedPrefix + command} <tiktok_url>`); | |
| } | |
| const url = args[0]; | |
| if (!/(?:tiktok\.com|vt\.tiktok\.com)/.test(url)) { | |
| return m.reply('Please provide a valid TikTok URL.'); | |
| } | |
| try { | |
| await conn.sendMessage(m.chat, { | |
| react: { | |
| text: 'π', | |
| key: m.key, | |
| } | |
| }); | |
| const apiResponse = await axios.get(`https://theresapis.vercel.app/download/tiktok?url=${encodeURIComponent(url)}`); | |
| const { | |
| data | |
| } = apiResponse; | |
| if (!data.status || data.result.code !== 0) { | |
| throw new Error(data.result.msg || 'Failed to download TikTok content.'); | |
| } | |
| const result = data.result.data; | |
| let caption = ` | |
| *Title:* ${result.title} | |
| *Author:* ${result.author.nickname} (@${result.author.unique_id}) | |
| β€οΈ *Likes:* ${result.digg_count.toLocaleString()} | |
| π¬ *Comments:* ${result.comment_count.toLocaleString()} | |
| π *Shares:* ${result.share_count.toLocaleString()} | |
| ποΈ *Views:* ${result.play_count.toLocaleString()} | |
| `.trim(); | |
| if (result.images && result.images.length > 0) { | |
| // Handle slideshow/images | |
| m.reply(caption); | |
| for (let i = 0; i < result.images.length; i++) { | |
| await conn.sendFile(m.chat, result.images[i], `tiktok_image_${i + 1}.jpeg`, '', m, false, { | |
| asDocument: false | |
| }); | |
| } | |
| } else if (result.play) { | |
| // Handle video | |
| await conn.sendFile(m.chat, result.play, 'tiktok.mp4', caption, m); | |
| } else { | |
| throw new Error('No downloadable media found in the response.'); | |
| } | |
| await conn.sendMessage(m.chat, { | |
| react: { | |
| text: 'β ', | |
| key: m.key, | |
| } | |
| }); | |
| } catch (error) { | |
| console.error('TikTok Download Error:', error); | |
| await conn.sendMessage(m.chat, { | |
| react: { | |
| text: 'β', | |
| key: m.key, | |
| } | |
| }); | |
| m.reply(`An error occurred: ${error.message || 'Unable to process your request.'}`); | |
| } | |
| }; | |
| handler.help = ['tiktok <url>']; | |
| handler.tags = ['downloader']; | |
| handler.command = /^(tiktok|tt|ttdl|tiktokdl)$/i; | |
| handler.description = 'Download TikTok videos or image slideshows without watermark.'; | |
| module.exports = handler; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment