(sock, message, args, context)
| 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 | }; |
nothing calls this directly
no test coverage detected