(sock: any, message: any, args: any, context: BotContext)
| 9 | usage: '.quote2', |
| 10 | |
| 11 | async handler(sock: any, message: any, args: any, context: BotContext) { |
| 12 | const chatId = context.chatId || message.key.remoteJid; |
| 13 | |
| 14 | try { |
| 15 | const res = await axios.get('https://discardapi.dpdns.org/api/quotes/random?apikey=guru'); |
| 16 | |
| 17 | if (!res.data || res.data.status !== true) { |
| 18 | return await sock.sendMessage(chatId, { text: '❌ Failed to fetch quote.' }, { quoted: message }); |
| 19 | } |
| 20 | |
| 21 | const quote = res.data.result?.quote || 'No quote found.'; |
| 22 | const _creator = res.data.creator || 'Unknown'; |
| 23 | |
| 24 | const replyText = `💬 *Random Quote*\n\n${quote}`; |
| 25 | |
| 26 | await sock.sendMessage(chatId, { text: replyText }, { quoted: message }); |
| 27 | |
| 28 | } catch(err: any) { |
| 29 | console.error('Quote plugin error:', err); |
| 30 | await sock.sendMessage(chatId, { text: '❌ Error while fetching quote.' }, { quoted: message }); |
| 31 | } |
| 32 | } |
| 33 | }; |
| 34 |
nothing calls this directly
no outgoing calls
no test coverage detected