Created
February 6, 2025 19:28
-
-
Save dipto-008/7a6b2daa7075cfba26997a9a431f9654 to your computer and use it in GitHub Desktop.
Hey noob ππ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const { execSync } = require('child_process'); | |
module.exports.config = { | |
name: "update", | |
version: "1.0.0", | |
role: 3, | |
author: "Dipto", | |
description: "Check for updates and apply them.", | |
usePrefix: true, | |
guide: "[confirm]", | |
category: "system", | |
countDown: 5, | |
}; | |
module.exports.run = async ({ message, args }) => { | |
try { | |
if (args[0] === 'confirm') { | |
await message.reply('Updating...'); | |
execSync('node update.js', { cwd: process.cwd() }); | |
await message.reply('Update completed.'); | |
} else { | |
execSync('node checkUpdates.js', { cwd: process.cwd() }); | |
const updateLog = fs.readFileSync('./update.log', 'utf-8'); | |
const info = await message.reply(`Update log:\n${updateLog}\n\nReply with "confirm" to apply updates.`); | |
global.functions.onReply.set(info.message_id, { | |
commandName: 'update', | |
type: 'confirmUpdate', | |
message_ID: info.message_id, | |
author: message.senderID, | |
}); | |
} | |
} catch (err) { | |
console.error('Error during update process:', err.message); | |
await message.reply(`Error: ${err.message}`); | |
} | |
}; | |
module.exports.onReply = async ({ message, event, Reply }) => { | |
if (Reply.commandName === 'update' && Reply.type === 'confirmUpdate') { | |
if (event.text.toLowerCase() === 'confirm') { | |
await message.reply('Updating...'); | |
execSync('node update.js', { cwd: process.cwd() }); | |
await message.reply('Update completed.'); | |
} else { | |
await message.reply('Update canceled.'); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment