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

Function pmblockerCommand

commands/pmblocker.js:32–69  ·  view source on GitHub ↗
(sock, chatId, message, args)

Source from the content-addressed store, hash-verified

30}
31
32async function pmblockerCommand(sock, chatId, message, args) {
33 const senderId = message.key.participant || message.key.remoteJid;
34 const isOwner = await isOwnerOrSudo(senderId, sock, chatId);
35
36 if (!message.key.fromMe && !isOwner) {
37 await sock.sendMessage(chatId, { text: 'Only bot owner can use this command!' }, { quoted: message });
38 return;
39 }
40
41 const argStr = (args || '').trim();
42 const [sub, ...rest] = argStr.split(' ');
43 const state = readState();
44
45 if (!sub || !['on', 'off', 'status', 'setmsg'].includes(sub.toLowerCase())) {
46 await sock.sendMessage(chatId, { text: '*PMBLOCKER (Owner only)*\n\n.pmblocker on - Enable PM auto-block\n.pmblocker off - Disable PM blocker\n.pmblocker status - Show current status\n.pmblocker setmsg <text> - Set warning message' }, { quoted: message });
47 return;
48 }
49
50 if (sub.toLowerCase() === 'status') {
51 await sock.sendMessage(chatId, { text: `PM Blocker is currently *${state.enabled ? 'ON' : 'OFF'}*\nMessage: ${state.message}` }, { quoted: message });
52 return;
53 }
54
55 if (sub.toLowerCase() === 'setmsg') {
56 const newMsg = rest.join(' ').trim();
57 if (!newMsg) {
58 await sock.sendMessage(chatId, { text: 'Usage: .pmblocker setmsg <message>' }, { quoted: message });
59 return;
60 }
61 writeState(state.enabled, newMsg);
62 await sock.sendMessage(chatId, { text: 'PM Blocker message updated.' }, { quoted: message });
63 return;
64 }
65
66 const enable = sub.toLowerCase() === 'on';
67 writeState(enable);
68 await sock.sendMessage(chatId, { text: `PM Blocker is now *${enable ? 'ENABLED' : 'DISABLED'}*.` }, { quoted: message });
69}
70
71module.exports = { pmblockerCommand, readState };
72

Callers

nothing calls this directly

Calls 3

isOwnerOrSudoFunction · 0.85
readStateFunction · 0.70
writeStateFunction · 0.70

Tested by

no test coverage detected