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

Function handler

plugins/ship.js:8–32  ·  view source on GitHub ↗
(sock, message, args, context)

Source from the content-addressed store, hash-verified

6 usage: '.ship',
7 groupOnly: true,
8 async handler(sock, message, args, context) {
9 const { chatId, channelInfo } = context;
10 try {
11 const participants = await sock.groupMetadata(chatId);
12 const ps = participants.participants.map((v) => v.id);
13 const firstUser = ps[Math.floor(Math.random() * ps.length)];
14 let secondUser;
15 do {
16 secondUser = ps[Math.floor(Math.random() * ps.length)];
17 } while (secondUser === firstUser);
18 const formatMention = (id) => `@${ id.split('@')[0]}`;
19 await sock.sendMessage(chatId, {
20 text: `${formatMention(firstUser)} ❤️ ${formatMention(secondUser)}\nCongratulations 💖🍻`,
21 mentions: [firstUser, secondUser],
22 ...channelInfo
23 });
24 }
25 catch (error) {
26 console.error('Error in ship command:', error);
27 await sock.sendMessage(chatId, {
28 text: '❌ Failed to ship! Make sure this is a group.',
29 ...channelInfo
30 }, { quoted: message });
31 }
32 }
33};

Callers

nothing calls this directly

Calls 1

formatMentionFunction · 0.85

Tested by

no test coverage detected