(sock, message, args, context)
| 7 | groupOnly: true, |
| 8 | adminOnly: true, |
| 9 | async handler(sock, message, args, context) { |
| 10 | const { chatId, channelInfo } = context; |
| 11 | const durationInMinutes = args[0] ? parseInt(args[0], 10) : undefined; |
| 12 | try { |
| 13 | await sock.groupSettingUpdate(chatId, 'announcement'); |
| 14 | if (durationInMinutes !== undefined && durationInMinutes > 0) { |
| 15 | const durationInMilliseconds = durationInMinutes * 60 * 1000; |
| 16 | await sock.sendMessage(chatId, { |
| 17 | text: `The group has been muted for ${durationInMinutes} minutes.`, |
| 18 | ...channelInfo |
| 19 | }, { quoted: message }); |
| 20 | setTimeout(async () => { |
| 21 | try { |
| 22 | await sock.groupSettingUpdate(chatId, 'not_announcement'); |
| 23 | await sock.sendMessage(chatId, { |
| 24 | text: 'The group has been unmuted.', |
| 25 | ...channelInfo |
| 26 | }); |
| 27 | } |
| 28 | catch (unmuteError) { |
| 29 | console.error('Error unmuting group:', unmuteError); |
| 30 | } |
| 31 | }, durationInMilliseconds); |
| 32 | } |
| 33 | else { |
| 34 | await sock.sendMessage(chatId, { |
| 35 | text: 'The group has been muted.', |
| 36 | ...channelInfo |
| 37 | }, { quoted: message }); |
| 38 | } |
| 39 | } |
| 40 | catch (error) { |
| 41 | console.error('Error muting/unmuting the group:', error); |
| 42 | await sock.sendMessage(chatId, { |
| 43 | text: 'An error occurred while muting/unmuting the group. Please try again.', |
| 44 | ...channelInfo |
| 45 | }, { quoted: message }); |
| 46 | } |
| 47 | } |
| 48 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected