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

Function handler

plugins/pull.ts:11–51  ·  view source on GitHub ↗
(sock: any, message: any)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

reloadCommandsMethod · 0.80

Tested by

no test coverage detected