(sock, message, args, context)
| 7 | description: 'Delete a plugin by name (owner only)', |
| 8 | usage: '.delplugin <plugin_name>', |
| 9 | async handler(sock, message, args, context) { |
| 10 | const chatId = context.chatId || message.key.remoteJid; |
| 11 | try { |
| 12 | if (!args || !args[0]) { |
| 13 | return await sock.sendMessage(chatId, { |
| 14 | text: `*🌟Example usage:*\n.delplugin main-menu` |
| 15 | }, { quoted: message }); |
| 16 | } |
| 17 | const pluginDir = join(process.cwd(), 'plugins'); |
| 18 | const pluginFiles = readdirSync(pluginDir).filter(f => f.endsWith('.js')); |
| 19 | const pluginNames = pluginFiles.map(f => f.replace('.js', '')); |
| 20 | if (!pluginNames.includes(args[0])) { |
| 21 | return await sock.sendMessage(chatId, { |
| 22 | text: `🗃️ This plugin doesn't exist!\n\nAvailable plugins:\n${pluginNames.join('\n')}` |
| 23 | }, { quoted: message }); |
| 24 | } |
| 25 | const filePath = join(pluginDir, `${args[0] }.js`); |
| 26 | unlinkSync(filePath); |
| 27 | await sock.sendMessage(chatId, { text: `⚠️ Plugin "${args[0]}.js" has been deleted.` }, { quoted: message }); |
| 28 | } |
| 29 | catch (err) { |
| 30 | console.error('rmplugin error:', err); |
| 31 | await sock.sendMessage(chatId, { text: `❌ Failed to delete plugin: ${err.message}` |
| 32 | }, { quoted: message }); |
| 33 | } |
| 34 | } |
| 35 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected