MCPcopy Create free account
hub / github.com/Xchristech2/Zenitsu-Bot / resetlinkCommand

Function resetlinkCommand

commands/resetlink.js:1–39  ·  view source on GitHub ↗
(sock, chatId, senderId)

Source from the content-addressed store, hash-verified

1async function resetlinkCommand(sock, chatId, senderId) {
2 try {
3 // Check if sender is admin
4 const groupMetadata = await sock.groupMetadata(chatId);
5 const isAdmin = groupMetadata.participants
6 .filter(p => p.admin)
7 .map(p => p.id)
8 .includes(senderId);
9
10 // Check if bot is admin
11 const botId = sock.user.id.split(':')[0] + '@s.whatsapp.net';
12 const isBotAdmin = groupMetadata.participants
13 .filter(p => p.admin)
14 .map(p => p.id)
15 .includes(botId);
16
17 if (!isAdmin) {
18 await sock.sendMessage(chatId, { text: '❌ Only admins can use this command!' });
19 return;
20 }
21
22 if (!isBotAdmin) {
23 await sock.sendMessage(chatId, { text: '❌ Bot must be admin to reset group link!' });
24 return;
25 }
26
27 // Reset the group link
28 const newCode = await sock.groupRevokeInvite(chatId);
29
30 // Send the new link
31 await sock.sendMessage(chatId, {
32 text: `✅ Group link has been successfully reset\n\n📌 New link:\nhttps://chat.whatsapp.com/${newCode}`
33 });
34
35 } catch (error) {
36 console.error('Error in resetlink command:', error);
37 await sock.sendMessage(chatId, { text: 'Failed to reset group link!' });
38 }
39}
40
41module.exports = resetlinkCommand;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected