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

Function handler

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

Source from the content-addressed store, hash-verified

7 usage: '.delreply <trigger>',
8 ownerOnly: true,
9 async handler(sock, message, args, context) {
10 const chatId = context.chatId || message.key.remoteJid;
11 const channelInfo = context.channelInfo || {};
12 if (!args || args.length === 0) {
13 return await sock.sendMessage(chatId, {
14 text: '❌ Please provide the trigger to delete.\n\nUsage: `.delreply hello`\nSee all triggers: `.listreplies`',
15 ...channelInfo
16 }, { quoted: message });
17 }
18 const trigger = args.join(' ').toLowerCase().trim();
19 const config = await initConfig();
20 const before = config.replies.length;
21 config.replies = config.replies.filter(r => r.trigger !== trigger);
22 if (config.replies.length === before) {
23 return await sock.sendMessage(chatId, {
24 text: `❌ No auto-reply found for *"${trigger}"*\n\nUse \`.listreplies\` to see all triggers.`,
25 ...channelInfo
26 }, { quoted: message });
27 }
28 await saveConfig(config);
29 await sock.sendMessage(chatId, {
30 text: `🗑️ *Auto-reply deleted!*\n\nTrigger *"${trigger}"* has been removed.`,
31 ...channelInfo
32 }, { quoted: message });
33 }
34};

Callers

nothing calls this directly

Calls 2

initConfigFunction · 0.90
saveConfigFunction · 0.90

Tested by

no test coverage detected