(sock, message, args, context)
| 7 | groupOnly: true, |
| 8 | adminOnly: true, |
| 9 | async handler(sock, message, args, context) { |
| 10 | const chatId = context.chatId || message.key.remoteJid; |
| 11 | const channelInfo = context.channelInfo || {}; |
| 12 | const isBotAdmin = context.isBotAdmin || false; |
| 13 | if (!isBotAdmin) { |
| 14 | return await sock.sendMessage(chatId, { |
| 15 | text: `❌ Bot needs to be an admin to change group settings.`, |
| 16 | ...channelInfo |
| 17 | }, { quoted: message }); |
| 18 | } |
| 19 | const setting = args[0]?.toLowerCase(); |
| 20 | if (!setting) { |
| 21 | return await sock.sendMessage(chatId, { |
| 22 | text: `╔════════════════╗\n` + |
| 23 | `║⚙️ *GROUP SETTINGS* ║\n` + |
| 24 | `╚════════════════╝\n\n` + |
| 25 | `📌 *Usage:* \`.gcset <option>\`\n\n` + |
| 26 | `────────────────────\n` + |
| 27 | `*💬 MESSAGE PERMISSIONS*\n` + |
| 28 | `🔒 *lock* — Only admins can send messages\n\n` + |
| 29 | `🔓 *unlock* — Everyone can send messages\n\n` + |
| 30 | `*🛠️ SETTINGS PERMISSIONS*\n` + |
| 31 | `🔒 *lockset* — Only admins can edit group info\n\n` + |
| 32 | `🔓 *unlockset* — Everyone can edit group info\n` + |
| 33 | `────────────────────`, |
| 34 | ...channelInfo |
| 35 | }, { quoted: message }); |
| 36 | } |
| 37 | const settingsMap = { |
| 38 | lock: { value: 'announcement', label: '🔒 Only admins can send messages' }, |
| 39 | unlock: { value: 'not_announcement', label: '🔓 Everyone can send messages' }, |
| 40 | lockset: { value: 'locked', label: '🔒 Only admins can edit group info' }, |
| 41 | unlockset: { value: 'unlocked', label: '🔓 Everyone can edit group info' }, |
| 42 | }; |
| 43 | const config = settingsMap[setting]; |
| 44 | if (!config) { |
| 45 | return await sock.sendMessage(chatId, { |
| 46 | text: `❌ Unknown setting: *${setting}*\n\nUse \`.groupsettings\` to see options.`, |
| 47 | ...channelInfo |
| 48 | }, { quoted: message }); |
| 49 | } |
| 50 | try { |
| 51 | await sock.groupSettingUpdate(chatId, config.value); |
| 52 | return await sock.sendMessage(chatId, { |
| 53 | text: `✅ ${config.label}`, |
| 54 | ...channelInfo |
| 55 | }, { quoted: message }); |
| 56 | } |
| 57 | catch (e) { |
| 58 | console.error('[GROUPSETTINGS] Error:', e.message); |
| 59 | return await sock.sendMessage(chatId, { |
| 60 | text: `❌ Failed to update setting: ${e.message}`, |
| 61 | ...channelInfo |
| 62 | }, { quoted: message }); |
| 63 | } |
| 64 | } |
| 65 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected