const removeDir = require('./remove_dir'); const copyFolder = require('./copyFolder'); const path = require('path'); const fs = require('fs'); async function restore(client) { try { await client.destroy() } catch (error) { console.error(`Error on try destroy client: ${error}`) } const sessionBackupPath = path.join(process.cwd(), `session_backup`, `session-omnihit_sesssion`) const sessionPath = path.join(process.cwd(), '.wwebjs_auth', 'session-omnihit_sesssion') if (fs.existsSync(path.join(process.cwd(), `session_backup`, `session-omnihit_sesssion`))) { await removeDir(sessionPath) // copy the good session for backup dir copyFolder(sessionBackupPath, sessionPath) } else { console.log('Directory not found to copy: ', sessionPath) } setTimeout(() => { console.log('process.exit: kkkkkkkkkkkkkkkkkkkkk') process.exit() }, 5000) } module.exports = restore;