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