(sock, message, args, context)
| 6 | description: 'Reverse any text', |
| 7 | usage: '.reverse <text>', |
| 8 | async handler(sock, message, args, context) { |
| 9 | const chatId = context.chatId || message.key.remoteJid; |
| 10 | const textToReverse = args?.join(' ')?.trim(); |
| 11 | if (!textToReverse) { |
| 12 | return await sock.sendMessage(chatId, { text: 'Please provide text to reverse.\nExample: .reverse Hello World' }, { quoted: message }); |
| 13 | } |
| 14 | try { |
| 15 | const apiUrl = `https://discardapi.dpdns.org/api/tools/reverse?apikey=guru&text=${encodeURIComponent(textToReverse)}`; |
| 16 | const { data } = await axios.get(apiUrl, { timeout: 10000 }); |
| 17 | if (!data?.status || !data.result) { |
| 18 | return await sock.sendMessage(chatId, { text: '❌ Failed to reverse the text.' }, { quoted: message }); |
| 19 | } |
| 20 | const reply = `*Reversed:* ${data.result}`; |
| 21 | await sock.sendMessage(chatId, { text: reply }, { quoted: message }); |
| 22 | } |
| 23 | catch (error) { |
| 24 | console.error('Reverse plugin error:', error); |
| 25 | if (error.code === 'ECONNABORTED') { |
| 26 | await sock.sendMessage(chatId, { text: '❌ Request timed out. Please try again.' }, { quoted: message }); |
| 27 | } |
| 28 | else { |
| 29 | await sock.sendMessage(chatId, { text: '❌ Failed to reverse the text.' }, { quoted: message }); |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected