Spaces:
Paused
Paused
πππππππ πππππππ β‘
commited on
Create update2.js
Browse files- plugins/update2.js +28 -0
plugins/update2.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
const config = require('../config');
|
| 3 |
+
const fs = require('fs');
|
| 4 |
+
const { execSync } = require('child_process');
|
| 5 |
+
const { cmd } = require('../command');
|
| 6 |
+
|
| 7 |
+
cmd({
|
| 8 |
+
pattern: "update",
|
| 9 |
+
react: "π",
|
| 10 |
+
desc: "Update bot",
|
| 11 |
+
category: "system",
|
| 12 |
+
use: '.update',
|
| 13 |
+
filename: __filename
|
| 14 |
+
}, async (conn, mek, m, { from, reply }) => {
|
| 15 |
+
try {
|
| 16 |
+
await conn.sendMessage(from, { text: 'Please wait... Updating bot...' }, { quoted: mek });
|
| 17 |
+
|
| 18 |
+
const repoUrl = `https://github.com/mrfrank-ofc/SUBZERO-MD`;
|
| 19 |
+
|
| 20 |
+
console.log("Updating repository using rsync...");
|
| 21 |
+
execSync(`rsync -avz --delete --exclude=.git ${repoUrl}/ ./`);
|
| 22 |
+
|
| 23 |
+
await conn.sendMessage(from, { text: '*β
Bot updated successfully!*' }, { quoted: mek });
|
| 24 |
+
} catch (error) {
|
| 25 |
+
console.error(error);
|
| 26 |
+
reply(`*Error during update:* ${error.message}`);
|
| 27 |
+
}
|
| 28 |
+
});
|