MCPcopy Create free account
hub / github.com/Xchristech2/Zenitsu-Bot / wastedCommand

Function wastedCommand

commands/wasted.js:4–54  ·  view source on GitHub ↗
(sock, chatId, message)

Source from the content-addressed store, hash-verified

2const { channelInfo } = require('../lib/messageConfig');
3
4async function wastedCommand(sock, chatId, message) {
5 let userToWaste;
6
7 // Check for mentioned users
8 if (message.message?.extendedTextMessage?.contextInfo?.mentionedJid?.length > 0) {
9 userToWaste = message.message.extendedTextMessage.contextInfo.mentionedJid[0];
10 }
11 // Check for replied message
12 else if (message.message?.extendedTextMessage?.contextInfo?.participant) {
13 userToWaste = message.message.extendedTextMessage.contextInfo.participant;
14 }
15
16 if (!userToWaste) {
17 await sock.sendMessage(chatId, {
18 text: 'Please mention someone or reply to their message to waste them!',
19 ...channelInfo
20 }, { quoted: message });
21 return;
22 }
23
24 try {
25 // Get user's profile picture
26 let profilePic;
27 try {
28 profilePic = await sock.profilePictureUrl(userToWaste, 'image');
29 } catch {
30 profilePic = 'https://i.imgur.com/2wzGhpF.jpeg'; // Default image if no profile pic
31 }
32
33 // Get the wasted effect image
34 const wastedResponse = await axios.get(
35 `https://some-random-api.com/canvas/overlay/wasted?avatar=${encodeURIComponent(profilePic)}`,
36 { responseType: 'arraybuffer' }
37 );
38
39 // Send the wasted image
40 await sock.sendMessage(chatId, {
41 image: Buffer.from(wastedResponse.data),
42 caption: `⚰️ *Wasted* : ${userToWaste.split('@')[0]} 💀\n\nRest in pieces!`,
43 mentions: [userToWaste],
44 ...channelInfo
45 });
46
47 } catch (error) {
48 console.error('Error in wasted command:', error);
49 await sock.sendMessage(chatId, {
50 text: 'Failed to create wasted image! Try again later.',
51 ...channelInfo
52 }, { quoted: message });
53 }
54}
55
56module.exports = wastedCommand;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected