(sock: any, message: any, args: any, context: BotContext)
| 1 | import type { BotContext } from '../types.js'; |
| 2 | import axios from 'axios'; |
| 3 | export default {command:'fact',aliases:['randomfact','uselessfact'],category:'fun',description:'Get a random interesting fact',usage:'.fact',async handler(sock: any, message: any, args: any, context: BotContext){ |
| 4 | const chatId=context.chatId||message.key.remoteJid; |
| 5 | try{ |
| 6 | const r=await axios.get('https://uselessfacts.jsph.pl/random.json?language=en'); |
| 7 | await sock.sendMessage(chatId,{text:r.data.text},{quoted:message}); |
| 8 | }catch(e: any) { |
| 9 | console.error('Error fetching fact:',e); |
| 10 | await sock.sendMessage(chatId,{text:'Sorry, I could not fetch a fact right now.'},{quoted:message}); |
| 11 | }}}; |
| 12 |
nothing calls this directly
no outgoing calls
no test coverage detected