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

Function handleAreactCommand

lib/reactions.js:62–103  ·  view source on GitHub ↗
(sock, chatId, message, isOwner)

Source from the content-addressed store, hash-verified

60
61// Function to handle areact command
62async function handleAreactCommand(sock, chatId, message, isOwner) {
63 try {
64 if (!isOwner) {
65 await sock.sendMessage(chatId, {
66 text: '❌ This command is only available for the owner!',
67 quoted: message
68 });
69 return;
70 }
71
72 const args = message.message?.conversation?.split(' ') || [];
73 const action = args[1]?.toLowerCase();
74
75 if (action === 'on') {
76 isAutoReactionEnabled = true;
77 saveAutoReactionState(true);
78 await sock.sendMessage(chatId, {
79 text: '✅ Auto-reactions have been enabled globally',
80 quoted: message
81 });
82 } else if (action === 'off') {
83 isAutoReactionEnabled = false;
84 saveAutoReactionState(false);
85 await sock.sendMessage(chatId, {
86 text: '✅ Auto-reactions have been disabled globally',
87 quoted: message
88 });
89 } else {
90 const currentState = isAutoReactionEnabled ? 'enabled' : 'disabled';
91 await sock.sendMessage(chatId, {
92 text: `Auto-reactions are currently ${currentState} globally.\n\nUse:\n.areact on - Enable auto-reactions\n.areact off - Disable auto-reactions`,
93 quoted: message
94 });
95 }
96 } catch (error) {
97 console.error('Error handling areact command:', error);
98 await sock.sendMessage(chatId, {
99 text: '❌ Error controlling auto-reactions',
100 quoted: message
101 });
102 }
103}
104
105module.exports = {
106 addCommandReaction,

Callers

nothing calls this directly

Calls 1

saveAutoReactionStateFunction · 0.85

Tested by

no test coverage detected