MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MDX / handler

Function handler

plugins/fact.ts:3–11  ·  view source on GitHub ↗
(sock: any, message: any, args: any, context: BotContext)

Source from the content-addressed store, hash-verified

1import type { BotContext } from '../types.js';
2import axios from 'axios';
3export 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){
4const chatId=context.chatId||message.key.remoteJid;
5try{
6const r=await axios.get('https://uselessfacts.jsph.pl/random.json?language=en');
7await sock.sendMessage(chatId,{text:r.data.text},{quoted:message});
8}catch(e: any) {
9console.error('Error fetching fact:',e);
10await sock.sendMessage(chatId,{text:'Sorry, I could not fetch a fact right now.'},{quoted:message});
11}}};
12

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected