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

Function handler

plugins/ship.ts:10–39  ·  view source on GitHub ↗
(sock: any, message: any, args: any, context: BotContext)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

formatMentionFunction · 0.85

Tested by

no test coverage detected