(sock, message, args, context)
| 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 | }; |
nothing calls this directly
no test coverage detected