Spaces:
Sleeping
Sleeping
const fetch = require("node-fetch"); | |
const { | |
cmd | |
} = require("../command"); | |
cmd({ | |
'pattern': "tiktoksearch", | |
'alias': ["tiktoks", "tiks"], | |
'desc': "Search for TikTok videos using a query.", | |
'react': 'β ', | |
'category': 'tools', | |
'filename': __filename | |
}, async (_0x5d6728, _0x5b3f91, _0x8dc722, { | |
from: _0x413f5e, | |
args: _0x33ddfe, | |
reply: _0x2b8cb3 | |
}) => { | |
if (!_0x33ddfe[0x0]) { | |
return _0x2b8cb3("πΈ What do you want to search on TikTok?\n\n*Usage Example:*\n.tiktoksearch <query>"); | |
} | |
const _0x36c4a3 = _0x33ddfe.join(" "); | |
await _0x8dc722.react('β'); | |
try { | |
_0x2b8cb3("π Searching TikTok for: " + _0x36c4a3); | |
const _0x29056a = await fetch('https://apis-starlights-team.koyeb.app/starlight/tiktoksearch?text=' + encodeURIComponent(_0x36c4a3)); | |
const _0x56ad0e = await _0x29056a.json(); | |
if (!_0x56ad0e || !_0x56ad0e.data || _0x56ad0e.data.length === 0x0) { | |
await _0x8dc722.react('β'); | |
return _0x2b8cb3("β No results found for your query. Please try with a different keyword."); | |
} | |
const _0x3df082 = _0x56ad0e.data.slice(0x0, 0x7); | |
_0x3df082.sort(() => Math.random() - 0.5); | |
for (const _0x1cbfc2 of _0x3df082) { | |
const _0x2a89a2 = "πΈ *SubZero TikTok Video Result*:\n\n*β’ Title*: " + _0x1cbfc2.title + "\n\n*β’ Author*: " + (_0x1cbfc2.author || 'Unknown') + "\n\n*β’ Duration*: " + (_0x1cbfc2.duration || "Unknown") + "\n\n*β’ URL*: " + _0x1cbfc2.link + "\n\n"; | |
if (_0x1cbfc2.nowm) { | |
await _0x5d6728.sendMessage(_0x413f5e, { | |
'video': { | |
'url': _0x1cbfc2.nowm | |
}, | |
'caption': _0x2a89a2 | |
}, { | |
'quoted': _0x8dc722 | |
}); | |
} else { | |
_0x2b8cb3("β Failed to retrieve video for \"" + _0x1cbfc2.title + "\"."); | |
} | |
} | |
await _0x8dc722.react('β '); | |
} catch (_0x41a380) { | |
console.error("Error in TikTokSearch command:", _0x41a380); | |
await _0x8dc722.react('β'); | |
_0x2b8cb3("β An error occurred while searching TikTok. Please try again later."); | |
} | |
}); | |