(sock, message, args, context)
| 6 | description: 'Search for stickers using Tenor', |
| 7 | usage: '.stickers <search term>', |
| 8 | async handler(sock, message, args, context) { |
| 9 | const chatId = context.chatId || message.key.remoteJid; |
| 10 | const text = args?.join(' ')?.trim(); |
| 11 | if (!text) { |
| 12 | return await sock.sendMessage(chatId, { text: '*Provide a search term.*\nExample: .stickers funny' }, { quoted: message }); |
| 13 | } |
| 14 | try { |
| 15 | await sock.sendMessage(chatId, { text: 'Searching for stickers...' }, { quoted: message }); |
| 16 | const { data } = await axios.get(`https://g.tenor.com/v1/search?q=${encodeURIComponent(text)}&key=LIVDSRZULELA&limit=8`); |
| 17 | if (!data?.results?.length) { |
| 18 | return await sock.sendMessage(chatId, { text: '❌ No stickers found.' }, { quoted: message }); |
| 19 | } |
| 20 | const limit = Math.min(data.results.length, 5); |
| 21 | for (let i = 0; i < limit; i++) { |
| 22 | const media = data.results[i].media?.[0]?.mp4?.url; |
| 23 | if (!media) |
| 24 | continue; |
| 25 | await sock.sendMessage(chatId, { video: { url: media }, caption: `Sticker ${i + 1}`, mimetype: 'video/mp4' }, { quoted: message }); |
| 26 | } |
| 27 | } |
| 28 | catch (error) { |
| 29 | console.error('StickerSearch plugin error:', error); |
| 30 | await sock.sendMessage(chatId, { text: '❌ Failed to fetch stickers.' }, { quoted: message }); |
| 31 | } |
| 32 | } |
| 33 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected