(sock: any, message: any, args: any, context: BotContext)
| 7 | description: 'Get a random cheems meme with buttons for another meme or joke', |
| 8 | usage: '.meme', |
| 9 | async handler(sock: any, message: any, args: any, context: BotContext) { |
| 10 | const chatId = context.chatId || message.key.remoteJid; |
| 11 | |
| 12 | try { |
| 13 | const res = await fetch('https://shizoapi.onrender.com/api/memes/cheems?apikey=shizo'); |
| 14 | |
| 15 | if (!res.ok) throw new Error(`API request failed with status ${res.status}`); |
| 16 | |
| 17 | const contentType = res.headers.get('content-type'); |
| 18 | |
| 19 | if (contentType && contentType.includes('image')) { |
| 20 | const imageBuffer = Buffer.from(await res.arrayBuffer()); |
| 21 | |
| 22 | const buttons = [ |
| 23 | { buttonId: '.meme', buttonText: { displayText: '🎭 Another Meme' }, type: 1 }, |
| 24 | { buttonId: '.joke', buttonText: { displayText: '😄 Joke' }, type: 1 } |
| 25 | ]; |
| 26 | |
| 27 | await sock.sendMessage(chatId, { |
| 28 | image: imageBuffer, |
| 29 | caption: "🐕 > Here's your cheems meme!", |
| 30 | buttons: buttons, |
| 31 | headerType: 1 |
| 32 | }, { quoted: message }); |
| 33 | |
| 34 | } else { |
| 35 | await sock.sendMessage(chatId, { |
| 36 | text: '❌ The API did not return a valid image.', |
| 37 | quoted: message |
| 38 | }); |
| 39 | } |
| 40 | |
| 41 | } catch(error: any) { |
| 42 | console.error('Meme Command Error:', error); |
| 43 | await sock.sendMessage(chatId, { |
| 44 | text: '❌ Failed to fetch meme. Please try again later.', |
| 45 | quoted: message |
| 46 | }); |
| 47 | } |
| 48 | } |
| 49 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected