(sock, message)
| 7 | usage: '.gitpull', |
| 8 | ownerOnly: true, |
| 9 | async handler(sock, message) { |
| 10 | const chatId = message.key.remoteJid; |
| 11 | const commandHandler = (await import('../lib/commandHandler.js')).default; |
| 12 | const git = simpleGit(); |
| 13 | const start = Date.now(); |
| 14 | let gitStatus = 'Local reload only'; |
| 15 | try { |
| 16 | const isRepo = await git.checkIsRepo(); |
| 17 | if (isRepo) { |
| 18 | const remotes = await git.getRemotes(true); |
| 19 | if (remotes.some((r) => r.name === 'origin')) { |
| 20 | await git.pull(); |
| 21 | gitStatus = 'Pulled from git remote'; |
| 22 | } |
| 23 | } |
| 24 | } |
| 25 | catch (err) { |
| 26 | gitStatus = 'Git unavailable, used local files'; |
| 27 | } |
| 28 | try { |
| 29 | commandHandler.reloadCommands(); |
| 30 | const end = Date.now(); |
| 31 | await sock.sendMessage(chatId, { |
| 32 | text: `✅ Reload complete\n` + |
| 33 | `🔄 Mode: ${gitStatus}\n` + |
| 34 | `📦 Plugins: ${commandHandler.commands.size}\n` + |
| 35 | `⏱ Time: ${end - start}ms` |
| 36 | }); |
| 37 | } |
| 38 | catch (error) { |
| 39 | await sock.sendMessage(chatId, { |
| 40 | text: `❌ Reload failed: ${error.message}` |
| 41 | }); |
| 42 | } |
| 43 | } |
| 44 | }; |
nothing calls this directly
no test coverage detected