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

Function handler

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

Source from the content-addressed store, hash-verified

6 description: 'Cancel a scheduled message by its ID',
7 usage: '.schedulecancel <ID>',
8 async handler(sock, message, args, context) {
9 const chatId = context.chatId || message.key.remoteJid;
10 const senderId = context.senderId || 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 schedule ID.\n\nUsage: `.schedulecancel <ID>`\nGet IDs: `.schedulelist`',
15 ...channelInfo
16 }, { quoted: message });
17 }
18 const targetId = args[0].toUpperCase();
19 const schedules = await loadSchedules();
20 const index = schedules.findIndex(s => s.id === targetId && (s.chatId === chatId || s.senderId === senderId));
21 if (index === -1) {
22 return await sock.sendMessage(chatId, {
23 text: `❌ No scheduled message found with ID *${targetId}*\n\nUse \`.schedulelist\` to see your scheduled messages.`,
24 ...channelInfo
25 }, { quoted: message });
26 }
27 const cancelled = schedules.splice(index, 1)[0];
28 await saveSchedules(schedules);
29 await sock.sendMessage(chatId, {
30 text: `🗑️ *Schedule Cancelled!*\n\n📌 *ID:* ${cancelled.id}\n💬 *Message:* ${cancelled.message}`,
31 ...channelInfo
32 }, { quoted: message });
33 }
34};

Callers

nothing calls this directly

Calls 2

loadSchedulesFunction · 0.90
saveSchedulesFunction · 0.90

Tested by

no test coverage detected