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

Function handler

plugins/setgname.js:9–30  ·  view source on GitHub ↗
(sock, message, args, context)

Source from the content-addressed store, hash-verified

7 groupOnly: true,
8 adminOnly: true,
9 async handler(sock, message, args, context) {
10 const chatId = context.chatId || message.key.remoteJid;
11 const name = args.join(' ').trim();
12 if (!name) {
13 await sock.sendMessage(chatId, {
14 text: '❌ *Please provide a group name*\n\nUsage: `.setgname <new name>`'
15 }, { quoted: message });
16 return;
17 }
18 try {
19 await sock.groupUpdateSubject(chatId, name);
20 await sock.sendMessage(chatId, {
21 text: `✅ *Group name updated to:*\n${name}`
22 }, { quoted: message });
23 }
24 catch (error) {
25 console.error('Error updating group name:', error);
26 await sock.sendMessage(chatId, {
27 text: '❌ *Failed to update group name*\n\nMake sure the bot is an admin.'
28 }, { quoted: message });
29 }
30 }
31};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected